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

Require addresses to pass the built-in EMAIL_REGEXP #33

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/activemodel_email_address_validator/email_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def valid_using_regex?(regex)

def valid_using_default?
return false if /(\s|["'<>,])+/.match?(address)
return false unless URI::MailTo::EMAIL_REGEXP.match?(address)
Comment on lines 36 to +37
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could remove the regex-check at line 36 without any regressions. I'd expect URI::MailtTo::EMAIL_REGEXP to handle those cases as well.


email_parts = address.split("@", -1)
return false unless email_parts.size == 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def test_rejects_username_with_quotation_mark
reject("email123@exa'mple.com")
end

def test_rejects_unmailable_usernames
reject("abdalah291]79@example.com")
end

private

def accept(email_address)
Expand Down
Loading