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

::URI::MailTo::EMAIL_REGEXP uses lowercase z for string-end anchor #43

Open
foohooboo opened this issue Jul 6, 2022 · 0 comments
Open

Comments

@foohooboo
Copy link

foohooboo commented Jul 6, 2022

::URI::MailTo::EMAIL_REGEXP == /\A[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])?)*\z/

Using the Regexp object works just fine. However, using the source in a rails query points out the error in the \z escape squence at the end..

User.where("email ~* ?", ::URI::MailTo::EMAIL_REGEXP) results in the following error:

ActiveRecord::StatementInvalid: PG::InvalidRegularExpression: ERROR: invalid regular expression: invalid escape \ sequence

::URI::MailTo::EMAIL_REGEXP.source == "\\A[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])?)*\\z"

The query is successful when I swap the lowercase z for an uppercase Z.

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

No branches or pull requests

1 participant