Fix email with empty domain name labels passing validation (#23246)
* Fix email with empty domain name labels passing validation `EmailMxValidator` would allow empty labels because `Resolv::DNS` is particularly lenient about them, but the email would be invalid and unusable. * Add tests
This commit is contained in:
parent
dd58db64d8
commit
a5a00d7f7a
2 changed files with 29 additions and 0 deletions
|
@ -10,6 +10,8 @@ class EmailMxValidator < ActiveModel::Validator
|
|||
|
||||
if domain.blank?
|
||||
user.errors.add(:email, :invalid)
|
||||
elsif domain.include?('..')
|
||||
user.errors.add(:email, :invalid)
|
||||
elsif !on_allowlist?(domain)
|
||||
resolved_ips, resolved_domains = resolve_mx(domain)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue