A platform for community discussion. Free, open, simple.
FIX: email receiver should ignore x-auto-response-suppress
Michael Brown076def505eab
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rbindex 73d468e4ac3..1d5a044d35f 100644--- a/lib/email/receiver.rb+++ b/lib/email/receiver.rb@@ -383,7 +383,7 @@ module Email@mail[:subject].to_s[/\A\s*(Auto:|Automatic reply|Autosvar|Automatisk svar|Automatisch antwoord|Abwesenheitsnotiz|Risposta Non al computer|Automatisch antwoord|Auto Response|Respuesta automática|Fuori sede|Out of Office|Frånvaro|Réponse automatique)/i] ||- @mail.header.to_s[+ @mail.header.reject { |h| h.name.downcase == "x-auto-response-suppress" }.to_s[/auto[\-_]?(response|submitted|replied|reply|generated|respond)|holidayreply|machinegenerated/i]enddiff --git a/spec/fixtures/emails/quirks_exchange_xars.eml b/spec/fixtures/emails/quirks_exchange_xars.emlnew file mode 100644index 00000000000..16bd2d60e34--- /dev/null+++ b/spec/fixtures/emails/quirks_exchange_xars.eml@@ -0,0 +1,10 @@+Return-Path: <[email protected]>+From: Foo Bar <[email protected]>+To: [email protected]+Date: Fri, 15 Jan 2016 00:12:43 +0100+Message-ID: <[email protected]>+Mime-Version: 1.0+Content-Type: text/plain; charset=UTF-8+X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply++Some thing.diff --git a/spec/lib/email/receiver_spec.rb b/spec/lib/email/receiver_spec.rbindex 99035646be8..4910880bc81 100644--- a/spec/lib/email/receiver_spec.rb+++ b/spec/lib/email/receiver_spec.rb@@ -521,6 +521,10 @@ RSpec.describe Email::Receiver doexpect { process(:invalid_from_2) }.to raise_error(Email::Receiver::NoSenderDetectedError)end+ it "doesn't raise an AutoGeneratedEmailError due to an X-Auto-Response-Suppress header" do+ expect { process(:quirks_exchange_xars) }.to change { topic.posts.count }+ end+it "doesn't raise an AutoGeneratedEmailError when the mail is auto generated but is allowlisted" doSiteSetting.auto_generated_allowlist = "[email protected]|[email protected]"expect { process(:auto_generated_allowlisted) }.to change { topic.posts.count }