Don't blow up when email has no References header
If an email doesn't match our incoming email patterns on the To header, we fall back to the References header. If there was no References header, we'd raise an exception, when we'd be better off acting as if it was empty.
This commit is contained in:
parent
6277bda61c
commit
08b1380ff7
3 changed files with 16 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Gracefully handle failures for incoming emails which do not match on the To
|
||||
header, and have no References header
|
||||
merge_request:
|
||||
author:
|
|
@ -70,6 +70,8 @@ module Gitlab
|
|||
# Handle emails from clients which append with commas,
|
||||
# example clients are Microsoft exchange and iOS app
|
||||
Gitlab::IncomingEmail.scan_fallback_references(references)
|
||||
when nil
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,9 +7,17 @@ describe Gitlab::Email::Receiver, lib: true do
|
|||
context "when we cannot find a capable handler" do
|
||||
let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "!!!") }
|
||||
|
||||
it "raises a UnknownIncomingEmail" do
|
||||
it "raises an UnknownIncomingEmail error" do
|
||||
expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
|
||||
end
|
||||
|
||||
context "and the email contains no references header" do
|
||||
let(:email_raw) { fixture_file("emails/auto_reply.eml").gsub(mail_key, "!!!") }
|
||||
|
||||
it "raises an UnknownIncomingEmail error" do
|
||||
expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when the email is blank" do
|
||||
|
|
Loading…
Reference in a new issue