0
0
Fork 0

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:
Claire 2023-01-24 20:18:41 +01:00 committed by GitHub
parent dd58db64d8
commit a5a00d7f7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View file

@ -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)