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

Validation regex generates a warning in Rails 4+ #18

Closed
danblaker opened this issue Dec 22, 2017 · 2 comments
Closed

Validation regex generates a warning in Rails 4+ #18

danblaker opened this issue Dec 22, 2017 · 2 comments

Comments

@danblaker
Copy link

validates self.slug_column, :format => { :with => /^[a-z0-9-]+$/, :message => "contains invalid characters. Only downcase letters, numbers, and '-' are allowed." }

Per Rails regex security guidelines, \A and \z should be used instead of ^ and $.

I stumbled upon this issue while using the Annotate gem, which generates the following warning while attempting to annotate models using slugs:

Unable to annotate app/models/sample_model.rb: The provided regular expression is using multiline anchors (^ or $), which may present a security risk. Did you mean to use \A and \z, or forgot to add the :multiline => true option?

@danblaker
Copy link
Author

This is addressed by pull request #16

@bkoski
Copy link
Owner

bkoski commented Nov 11, 2018

This is now fixed, via 20a6987 and #16

@bkoski bkoski closed this as completed Nov 11, 2018
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