summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-21 11:45:03 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-21 14:58:18 +0200
commit51ad59e0d880de4633d18af583be015af229b97d (patch)
tree12354107f31c6db79790bf3cb3803b26bbce8cd8
parent76aade28e25d1f6e8924b35ed9bd365c8889987f (diff)
downloadgitlab-ce-issue-body-code-mentions.tar.gz
Fix bug causing `@whatever` inside code blocks to sometimes be picked up as a user mention.issue-body-code-mentions
-rw-r--r--CHANGELOG3
-rw-r--r--app/models/concerns/mentionable.rb2
-rw-r--r--lib/gitlab/reference_extractor.rb4
3 files changed, 5 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b4affd5217a..8d2099e8cf6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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)
- Fix clone URL field and X11 Primary selection (Dmitry Medvinsky)
- 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.
-
-
-
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index acd9a1edc48..aad5e514793 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -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.
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index a502a8fe9cd..634f70347b5 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -18,8 +18,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)