Don't match email addresses or foo@bar as user references
This commit is contained in:
parent
322c9be816
commit
371ae05c15
3 changed files with 10 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
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}>"
|
||||
|
|
Loading…
Reference in a new issue