Project

General

Profile

Defect #42584 » fix-email-address-domain_in.patch

Go MAEDA, 2025-04-15 11:17

View differences:

app/models/email_address.rb
# Returns true if domain belongs to domains list.
def self.domain_in?(domain, domains)
domain = domain.downcase
domain = domain.to_s.downcase
domains = domains.to_s.split(/[\s,]+/) unless domains.is_a?(Array)
domains.reject(&:blank?).map(&:downcase).any? do |s|
s.start_with?('.') ? domain.end_with?(s) : domain == s
test/unit/email_address_test.rb
end
end
def test_domain_in_should_not_raise_exception_when_domain_is_nil
assert_nothing_raised do
assert_not EmailAddress.domain_in?(nil, 'example.com')
end
end
def test_should_reject_invalid_email
assert_not EmailAddress.new(address: 'invalid,email@example.com').valid?
end
(1-1/2)