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

Allow apostrophes in email address #12729

Merged
merged 1 commit into from
Nov 17, 2016

Conversation

imtayadeway
Copy link
Contributor

@imtayadeway imtayadeway commented Nov 17, 2016

The email validation regex is too restrictive and does not allow
apostrophes.

Even with this change, the regex is probably still too
restrictive. I am personally in favor of advice outlined in
this post,
which is, to summarize:

  1. Don't validate emails with regex, send an email to it instead
  2. If you must, use a very permissive one

Since both (1) is probably beyond the scope of this bugfix, and (2)
breaks existing tests (and I don't know if there are good reasons for
their being there), I want to recommend that we fix the specific problem
outlined in the BZ first, and try to address the general problem in a
follow up.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1379420

@miq-bot add-label bug, core, blocker
@miq-bot assign @gtanzillo

The email validation regex is too restrictive and does not allow
apostrophes.

Even with this change, the regex is probably still too
restrictive. I am personally in favor of advice outlined in
[this post](https://davidcel.is/posts/stop-validating-email-addresses-with-regex/),
which is, to summarize:

1) Don't validate emails with regex, send an email to it instead
2) If you must, use a very permissive one

Since both (1) is probably beyond the scope of this bugfix, and (2)
breaks existing tests (and I don't know if there are good reasons for
their being there), I want to recommend that we fix the specific problem
outlined in the BZ first, and try to address the general problem in a
follow up.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1379420
@miq-bot
Copy link
Member

miq-bot commented Nov 17, 2016

Checked commit imtayadeway@959d6f0 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 1 offense detected

app/models/user.rb

  • ❗ - Line 39, Col 3 - Rails/Validation - Prefer the new style validations validates :column, format: value over validates_format_of.

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@gtanzillo gtanzillo added this to the Sprint 50 Ending Dec 5, 2016 milestone Nov 17, 2016
@gtanzillo gtanzillo merged commit f728774 into ManageIQ:master Nov 17, 2016
@chessbyte
Copy link
Member

@@ -36,7 +36,7 @@ class User < ApplicationRecord

validates_presence_of :name, :userid
validates :userid, :uniqueness => {:conditions => -> { in_my_region } }
validates_format_of :email, :with => /\A([\w\.\-\+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i,
validates_format_of :email, :with => /\A([\w\.\-\+']+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i,
Copy link
Member

Choose a reason for hiding this comment

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

@imtayadeway @gtanzillo Maybe this regex should be used, instead?

chessbyte pushed a commit that referenced this pull request Nov 20, 2016
@chessbyte
Copy link
Member

Euwe Backport details:

$ git log -1
commit 6da4b096e7bd0bf6d232f34e2e4269a4b4761b0f
Author: Gregg Tanzillo <[email protected]>
Date:   Thu Nov 17 17:21:11 2016 -0500

    Merge pull request #12729 from imtayadeway/fix/email-validation

    Allow apostrophes in email address
    (cherry picked from commit f728774fb1db4c4e48246f27dbb9f0f50a4162d8)

    https://bugzilla.redhat.com/show_bug.cgi?id=1396489

chessbyte pushed a commit that referenced this pull request Dec 13, 2016
@chessbyte
Copy link
Member

Darga Backport details:

$ git log -1
commit b913c33bdcad5bc30ae8f280fda3cc0bb27c4ebb
Author: Gregg Tanzillo <[email protected]>
Date:   Thu Nov 17 17:21:11 2016 -0500

    Merge pull request #12729 from imtayadeway/fix/email-validation
    
    Allow apostrophes in email address
    (cherry picked from commit f728774fb1db4c4e48246f27dbb9f0f50a4162d8)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1396490

@imtayadeway imtayadeway deleted the fix/email-validation branch February 13, 2017 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants