Commit dd7449b9 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'dm-emails-are-not-user-references' into 'master'

Don't match email addresses or foo@bar as user references

See merge request !11837
parents 69e31003 371ae05c
Pipeline #8690088 failed with stages
in 87 minutes and 55 seconds
......@@ -369,6 +369,7 @@ class User < ActiveRecord::Base
# Pattern used to extract `@user` user references from text
def reference_pattern
%r{
(?<!\w)
#{Regexp.escape(reference_prefix)}
(?<user>#{Gitlab::PathRegex::FULL_NAMESPACE_FORMAT_REGEX})
}x
......
---
title: Don't match email addresses or foo@bar as user references
merge_request:
author:
......@@ -16,6 +16,11 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do
expect(reference_filter(act).to_html).to eq(exp)
end
it 'ignores references with text before the @ sign' do
exp = act = "Hey foo#{reference}"
expect(reference_filter(act).to_html).to eq(exp)
end
%w(pre code a style).each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Hey #{reference}</#{elem}>"
......
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