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

autoEscape=false not working #65

Open
hong1997 opened this issue Sep 26, 2018 · 3 comments
Open

autoEscape=false not working #65

hong1997 opened this issue Sep 26, 2018 · 3 comments

Comments

@hong1997
Copy link

autoEscape: Escape characters in searchWords which are meaningful in regular expressions.
However, when input ‘***x’, the component crashes.

@bvaughn
Copy link
Owner

bvaughn commented Sep 26, 2018

Auto escape escapes special characters like "." — but "***x" isn't a valid regexp. Still it shouldn't crash.

If you'd like to contribute a bug fix that would be nice!

@gndelia
Copy link

gndelia commented Oct 10, 2019

I could try and take a look 😄

@gndelia
Copy link

gndelia commented Oct 10, 2019

The problem seems to be in highlight-words-core package. Essentially, it is trying to create a regex from ***x but that fails. You can try it in the devTools console

new RegExp('***x')

returns

VM127:1 Uncaught SyntaxError: Invalid regular expression: /***x/: Nothing to repeat
at new RegExp ()
at :1:1

I am unsure how to proceed - applying autoEscape=true escapes the special characters and it seems to fix the issue.

Should we log a warning and return an empty array, as "not matching"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants