Skip to content

Commit

Permalink
Require addresses to pass the built-in EMAIL_REGEXP
Browse files Browse the repository at this point in the history
  • Loading branch information
prognostikos committed Mar 27, 2024
1 parent 132704e commit 25c9f96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/activemodel_email_address_validator/email_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def valid_using_regex?(regex)
end

def valid_using_default?
return false if /(\s|["'<>])+/.match?(address)
return false if /(\s|["'<>,])+/.match?(address)
return false unless URI::MailTo::EMAIL_REGEXP.match?(address)

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 @@ -136,6 +136,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

0 comments on commit 25c9f96

Please sign in to comment.