mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
FIX: surround the FROM alias with " in order to support the @ character
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user