Commit 6a7711cd authored by Chantal Rollison's avatar Chantal Rollison

Port of ccr/regexp_anchor to EE

parent db32e49e
title: Add anchor for incoming email regex
merge_request: !18917
type: added
...@@ -59,7 +59,7 @@ module Gitlab ...@@ -59,7 +59,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
......
...@@ -84,6 +84,10 @@ describe Gitlab::IncomingEmail do ...@@ -84,6 +84,10 @@ describe Gitlab::IncomingEmail 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
context "on GitLab.com" do context "on GitLab.com" do
before do before do
allow(Gitlab).to receive(:com?).and_return(true) allow(Gitlab).to receive(:com?).and_return(true)
......
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