mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 16:29:32 +08:00
Upgrade mail gem to remove dependency on mime-types.
* Use a EmailValidator.email_regexp for `Email.is_valid?` check as we're seeing an increase in allocation when parsing email addresses wih `Mail::Address`.
This commit is contained in:
11
lib/email.rb
11
lib/email.rb
@ -8,16 +8,7 @@ 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.split(".").size > 1
|
||||
rescue Mail::Field::ParseError
|
||||
false
|
||||
!!(EmailValidator.email_regex =~ email)
|
||||
end
|
||||
|
||||
def self.downcase(email)
|
||||
|
Reference in New Issue
Block a user