Commit be73838b authored by Chantal Rollison's avatar Chantal Rollison

Add anchor for incoming email regex, closes 44989

parent aa3004c4
title: Add anchor for incoming email regex
merge_request: !18917
type: added
...@@ -57,7 +57,7 @@ module Gitlab ...@@ -57,7 +57,7 @@ module Gitlab
regex = Regexp.escape(wildcard_address) regex = Regexp.escape(wildcard_address)
regex = regex.sub(Regexp.escape(WILDCARD_PLACEHOLDER), '(.+)') regex = regex.sub(Regexp.escape(WILDCARD_PLACEHOLDER), '(.+)')
Regexp.new(regex).freeze Regexp.new(/\A#{regex}\z/).freeze
end end
end end
end end
......
...@@ -83,6 +83,10 @@ describe Gitlab::IncomingEmail do ...@@ -83,6 +83,10 @@ describe Gitlab::IncomingEmail do
it "returns reply key" do it "returns reply key" do
expect(described_class.key_from_address("replies+key@example.com")).to eq("key") expect(described_class.key_from_address("replies+key@example.com")).to eq("key")
end end
it 'does not match emails with extra bits' do
expect(described_class.key_from_address('somereplies+somekey@example.com.someotherdomain.com')).to be nil
end
end end
context 'self.key_from_fallback_message_id' do context 'self.key_from_fallback_message_id' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment