diff options
author | Sean McGivern <sean@gitlab.com> | 2017-05-01 14:25:04 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-05-01 14:25:04 +0100 |
commit | 08b1380ff712f46a6005d366a9159a3e81674fb7 (patch) | |
tree | f705a00d394168008f2e189dc7e950b130e48da1 | |
parent | 6277bda61c511696f9d12fae4238b5214a722571 (diff) | |
download | gitlab-ce-08b1380ff712f46a6005d366a9159a3e81674fb7.tar.gz |
Don't blow up when email has no References headerdont-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.
-rw-r--r-- | changelogs/unreleased/dont-blow-up-when-email-has-no-references-header.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/email/receiver.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/email/receiver_spec.rb | 10 |
3 files changed, 16 insertions, 1 deletions
diff --git a/changelogs/unreleased/dont-blow-up-when-email-has-no-references-header.yml b/changelogs/unreleased/dont-blow-up-when-email-has-no-references-header.yml new file mode 100644 index 00000000000..a4345b70744 --- /dev/null +++ b/changelogs/unreleased/dont-blow-up-when-email-has-no-references-header.yml @@ -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: diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb index 419d56a51e0..c270c0ea9ff 100644 --- a/lib/gitlab/email/receiver.rb +++ b/lib/gitlab/email/receiver.rb @@ -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 diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb index 2a86b427806..f127e45ae6a 100644 --- a/spec/lib/gitlab/email/receiver_spec.rb +++ b/spec/lib/gitlab/email/receiver_spec.rb @@ -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 |