From a5a00d7f7adff5e0afbd23ac1e1b16120137509a Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 24 Jan 2023 20:18:41 +0100 Subject: 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 --- app/validators/email_mx_validator.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/validators/email_mx_validator.rb b/app/validators/email_mx_validator.rb index 20f2fd37c..19c57bdf6 100644 --- a/app/validators/email_mx_validator.rb +++ b/app/validators/email_mx_validator.rb @@ -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) -- cgit