summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-02-17 11:36:53 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-02-17 11:36:53 +0000
commit729a3c076b8f9eea7c41b3cc6c268f122eddb522 (patch)
treef2a9f05cff3b8c12692928a8bf6d33a16ccca491 /lib
parentaa792b91bbddeeb61ce77f9525fcaf238a9ad331 (diff)
parent02aad721f16a8eb4d5fd7499693614dadfa64770 (diff)
downloadgitlab-ce-729a3c076b8f9eea7c41b3cc6c268f122eddb522.tar.gz
Merge branch 'only-yield-valid-reference-matches' into 'master'
Only yield valid references in ReferenceFilter.references_in Closes #27648 See merge request !9318
Diffstat (limited to 'lib')
-rw-r--r--lib/banzai/filter/abstract_reference_filter.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb
index 955d857c679..3b15ff6566f 100644
--- a/lib/banzai/filter/abstract_reference_filter.rb
+++ b/lib/banzai/filter/abstract_reference_filter.rb
@@ -33,7 +33,12 @@ module Banzai
# Returns a String replaced with the return of the block.
def self.references_in(text, pattern = object_class.reference_pattern)
text.gsub(pattern) do |match|
- yield match, $~[object_sym].to_i, $~[:project], $~[:namespace], $~
+ symbol = $~[object_sym]
+ if object_class.reference_valid?(symbol)
+ yield match, symbol.to_i, $~[:project], $~[:namespace], $~
+ else
+ match
+ end
end
end