FIX: surround the FROM alias with " in order to support the @ character

This commit is contained in:
Régis Hanol
2017-03-07 23:37:21 +01:00
parent 0c03ccb01e
commit ee9d621d9c
3 changed files with 19 additions and 19 deletions

View File

@ -7,15 +7,15 @@ require_dependency 'email/styles'
module Email
def self.is_valid?(email)
return false unless String === email
parsed = Mail::Address.new(email)
# Don't allow for a TLD by itself list (sam@localhost)
# The Grammar is: (local_part "@" domain) / local_part ... need to discard latter
parsed.address == email && parsed.local != parsed.address && parsed.domain && parsed.domain.split(".").length > 1
parsed.address == email &&
parsed.local != parsed.address &&
parsed&.domain.split(".").size > 1
rescue Mail::Field::ParseError
false
end
@ -26,8 +26,7 @@ module Email
end
def self.cleanup_alias(name)
# TODO: I'm sure there are more, but I can't find a list
name ? name.gsub(/[:<>,]/, '') : name
name ? name.gsub(/[:<>,"]/, '') : name
end
end