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

Fix string with pattern where regular expression contains a double quote #111

Merged
merged 2 commits into from
Feb 9, 2020
Merged

Fix string with pattern where regular expression contains a double quote #111

merged 2 commits into from
Feb 9, 2020

Conversation

FranzZemen
Copy link
Contributor

For the string rule with pattern, if the regular expression contains a double quote an invalid token error occurs in the message field. This is because the RegExp.toString does not escape the internal double quote and the construction of the message concatenates double quotes to this value.

You can test this with sample regular expression /^[a-z0-9 .-'?!":;\/,_]+$/i

In this pull request, when constructing the message I replace the double quote with an escaped version, but due to the internal processing I have to also escape the escape character (\").

Jest reports 100% success for all tests plus the additional test I added.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 47bc2da on FranzZemen:master into b166f8c on icebob:master.

Copy link
Owner

@icebob icebob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Thank you very much for your PR!

@icebob icebob merged commit d29340f into icebob:master Feb 9, 2020
@icebob
Copy link
Owner

icebob commented Feb 9, 2020

Released in 1.0.2

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

Successfully merging this pull request may close these issues.

3 participants