Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-03-03 22:06:17 +0300
committerStan Hu <stanhu@gmail.com>2015-03-20 00:37:35 +0300
commit83d552d50d5485950052a8b9fcba384b81f33c43 (patch)
tree4cd793d3827467d70eae333df6acd1374aedfd1c /lib/gitlab/reference_extractor.rb
parent6c1074e302fd77e87c454cede145dd92f15d0c55 (diff)
Disable reference creation for comments surrounded by code/preformatted blocks
Diffstat (limited to 'lib/gitlab/reference_extractor.rb')
-rw-r--r--lib/gitlab/reference_extractor.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index 5b9772de168..1058d4c43d9 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -11,7 +11,13 @@ module Gitlab
end
def analyze(string, project)
- parse_references(string.dup, project)
+ text = string.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| '' }
+
+ parse_references(text, project)
end
# Given a valid project, resolve the extracted identifiers of the requested type to