From eff82c43d25675270feae1129bd2cfe3f71a4658 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 30 Oct 2022 14:44:55 -0500 Subject: [PATCH] emails: fix validation of undeliverable email addresses. * Fix bug where bogus domains weren't found because we checked for `nil?` instead of `blank?`. * Fix bug where bogus names weren't found because we used a nonexistent variable in the RCPT TO check (`to_address` instead of `address`). --- app/logical/danbooru/email_address.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/logical/danbooru/email_address.rb b/app/logical/danbooru/email_address.rb index 5eb7111c7..c50254aac 100644 --- a/app/logical/danbooru/email_address.rb +++ b/app/logical/danbooru/email_address.rb @@ -334,7 +334,7 @@ module Danbooru # still fail if the mailbox doesn't exist and the server lied to the RCPT TO command. def undeliverable?(from_address: Danbooru.config.contact_email, timeout: 3, allow_smtp: false) mail_server = mx_domain(timeout: timeout) - return true if mail_server.nil? + return true if mail_server.blank? return false if !allow_smtp smtp = Net::SMTP.new(mail_server) @@ -346,7 +346,7 @@ module Danbooru conn.mailfrom(from_address) # Net::SMTPFatalError is raised if RCPT TO returns a 5xx error. - response = conn.rcptto(to_address) rescue $! + response = conn.rcptto(address) rescue $! return response.is_a?(Net::SMTPFatalError) end rescue