Commit 285ae60c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'issue-body-code-mentions' into 'master'

Fix bug causing at-username inside code blocks to sometimes be picked up as a user mention.

Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2254.

See merge request !553
parents 67996c1e 51ad59e0
......@@ -6,6 +6,9 @@ v 7.11.0 (unreleased)
- Fix "Cannot move project" error message from popping up after a successful transfer (Stan Hu)
-
- Add "Reply quoting selected text" shortcut key (`r`)
- Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention.
- Fix bug causing `@whatever` inside an inline code snippet (backtick-style) to be picked up as a user mention.
-
-
-
-
......
......@@ -28,7 +28,7 @@ module Mentionable
# Construct a String that contains possible GFM references.
def mentionable_text
self.class.mentionable_attrs.map { |attr| send(attr) || '' }.join
self.class.mentionable_attrs.map { |attr| send(attr) }.compact.join("\n\n")
end
# The GFM reference to this Mentionable, which shouldn't be included in its #references.
......
......@@ -16,8 +16,8 @@ module Gitlab
text = text.dup
# Remove preformatted/code blocks so that references are not included
text.gsub!(%r{<pre>.*?</pre>|<code>.*?</code>}m) { |match| '' }
text.gsub!(%r{^```.*?^```}m) { |match| '' }
text.gsub!(/^```.*?^```/m, '')
text.gsub!(/[^`]`[^`]*?`[^`]/, '')
@references = Hash.new { |hash, type| hash[type] = [] }
parse_references(text)
......
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