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

Bad Code Generated #97

Open
lordnynex opened this issue Oct 18, 2020 · 1 comment
Open

Bad Code Generated #97

lordnynex opened this issue Oct 18, 2020 · 1 comment

Comments

@lordnynex
Copy link

When a regex contains backticks, they are not properly escaped.

The following regex for validating email addresses will re-produce this issue

"^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
@ak89224
Copy link

ak89224 commented Mar 16, 2021

I also faced the same issue and looked the code to find that,
As, for code generation for regex compilation raw string is used here and It’s not possible to include a backtick in a raw string literal. So, just remove the backtick from the regex expression.
Use this one as a workaround :
"^[a-zA-Z0-9.!#$%&'*+/=?^_{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"

@mwitkow

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

2 participants