Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doing fuzzy filtering doesn't escape regex characters like the non fuzzy case. #700

Closed
thecontstruct opened this issue Mar 7, 2017 · 2 comments · Fixed by #1059
Closed

Comments

@thecontstruct
Copy link

When using fuzzy:true for filtering with just a string query, the filter extension code doesn't _escapeRegex the characters used to build up the fuzzy regex.

Filtering for something like .* will throw a JS exception. The constructed fuzzy regex looks like this
.[^*]** which is invalid.

Would expect it to produce \.[^\*]*\* which matches properly.

Seeing this in Chrome 56
jquery 1.10.1
fancytree 2.21

I have a fix in mind for this already and will try to get a PR up for it in the next few days.

@mar10
Copy link
Owner

mar10 commented May 29, 2017

Any updates here?

@mar10 mar10 closed this as completed Jun 24, 2017
@stagefright5
Copy link
Contributor

stagefright5 commented Nov 24, 2020

Just a reminder that this is not yet fixed: (filter = "cs\")

image

stagefright5 added a commit to stagefright5/fancytree that referenced this issue Dec 25, 2020
Escaping the `filter` directly will not work because,
it gets further split into individual characters.
So, escape each character after splitting

closes  mar10#700
mar10 added a commit that referenced this issue Dec 27, 2020
* Changes to pkg and pkg lock files after `npm i`

* fix (ext-filter): escape regex for fuzzy filter

Escaping the `filter` directly will not work because,
it gets further split into individual characters.
So, escape each character after splitting

closes  #700

* fix (ext-filter): Highlight not working for fuzzy matched chars

Use regex capture group to compute the indices of the
matching character and then highlight them.

closes #1051

* playground for ext-filter

* add unit tests for the fuzzy match highlight fix

* simpler condition and comments

* filter test the equality of filter and highlighted chars

* cache exotic char regex in filter cb's closure

* cache exotic char only if `escapeTitles` is truthy

* Update CHANGELOG.md

Co-authored-by: Martin Wendt <github@wwwendt.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants