Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
371ae05c
Commit
371ae05c
authored
May 31, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't match email addresses or foo@bar as user references
parent
322c9be8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
0 deletions
+10
-0
app/models/user.rb
app/models/user.rb
+1
-0
changelogs/unreleased/dm-emails-are-not-user-references.yml
changelogs/unreleased/dm-emails-are-not-user-references.yml
+4
-0
spec/lib/banzai/filter/user_reference_filter_spec.rb
spec/lib/banzai/filter/user_reference_filter_spec.rb
+5
-0
No files found.
app/models/user.rb
View file @
371ae05c
...
@@ -369,6 +369,7 @@ class User < ActiveRecord::Base
...
@@ -369,6 +369,7 @@ class User < ActiveRecord::Base
# Pattern used to extract `@user` user references from text
# Pattern used to extract `@user` user references from text
def
reference_pattern
def
reference_pattern
%r{
%r{
(?<!
\w
)
#{
Regexp
.
escape
(
reference_prefix
)
}
#{
Regexp
.
escape
(
reference_prefix
)
}
(?<user>
#{
Gitlab
::
PathRegex
::
FULL_NAMESPACE_FORMAT_REGEX
}
)
(?<user>
#{
Gitlab
::
PathRegex
::
FULL_NAMESPACE_FORMAT_REGEX
}
)
}x
}x
...
...
changelogs/unreleased/dm-emails-are-not-user-references.yml
0 → 100644
View file @
371ae05c
---
title
:
Don't match email addresses or foo@bar as user references
merge_request
:
author
:
spec/lib/banzai/filter/user_reference_filter_spec.rb
View file @
371ae05c
...
@@ -16,6 +16,11 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do
...
@@ -16,6 +16,11 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do
expect
(
reference_filter
(
act
).
to_html
).
to
eq
(
exp
)
expect
(
reference_filter
(
act
).
to_html
).
to
eq
(
exp
)
end
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
|
%w(pre code a style)
.
each
do
|
elem
|
it
"ignores valid references contained inside '
#{
elem
}
' element"
do
it
"ignores valid references contained inside '
#{
elem
}
' element"
do
exp
=
act
=
"<
#{
elem
}
>Hey
#{
reference
}
</
#{
elem
}
>"
exp
=
act
=
"<
#{
elem
}
>Hey
#{
reference
}
</
#{
elem
}
>"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment