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
This commit is contained in:
commit
285ae60c15
3 changed files with 6 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue