about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-01-24 20:18:41 +0100
committerGitHub <noreply@github.com>2023-01-24 20:18:41 +0100
commita5a00d7f7adff5e0afbd23ac1e1b16120137509a (patch)
tree257d56b90af020f8c8b7c9a0bd4d3f26e3b034bc /app
parentdd58db64d87896698a840b6cffe06a0e816674ef (diff)
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
Diffstat (limited to 'app')
-rw-r--r--app/validators/email_mx_validator.rb2
1 files changed, 2 insertions, 0 deletions
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)