Commit 51ad59e0 authored by Douwe Maan's avatar Douwe Maan

Fix bug causing `@whatever` inside code blocks to sometimes be picked up as a user mention.

parent 76aade28
...@@ -3,7 +3,8 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -3,7 +3,8 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.11.0 (unreleased) v 7.11.0 (unreleased)
- Fix clone URL field and X11 Primary selection (Dmitry Medvinsky) - Fix clone URL field and X11 Primary selection (Dmitry Medvinsky)
- Ignore invalid lines in .gitmodules - Ignore invalid lines in .gitmodules
- - 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 ...@@ -28,7 +28,7 @@ module Mentionable
# Construct a String that contains possible GFM references. # Construct a String that contains possible GFM references.
def mentionable_text 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 end
# The GFM reference to this Mentionable, which shouldn't be included in its #references. # The GFM reference to this Mentionable, which shouldn't be included in its #references.
......
...@@ -18,8 +18,8 @@ module Gitlab ...@@ -18,8 +18,8 @@ module Gitlab
text = text.dup text = text.dup
# Remove preformatted/code blocks so that references are not included # Remove preformatted/code blocks so that references are not included
text.gsub!(%r{<pre>.*?</pre>|<code>.*?</code>}m) { |match| '' } text.gsub!(/^```.*?^```/m, '')
text.gsub!(%r{^```.*?^```}m) { |match| '' } text.gsub!(/[^`]`[^`]*?`[^`]/, '')
@references = Hash.new { |hash, type| hash[type] = [] } @references = Hash.new { |hash, type| hash[type] = [] }
parse_references(text) 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