From 94919c7ef6cf5786d380ae65623de0697eff9188 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 2 Jun 2015 13:17:21 +0200 Subject: Ignore references in blockquotes. --- lib/gitlab/markdown/reference_filter.rb | 14 ++++++++++---- lib/gitlab/reference_extractor.rb | 3 ++- spec/lib/gitlab/reference_extractor_spec.rb | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/gitlab/markdown/reference_filter.rb b/lib/gitlab/markdown/reference_filter.rb index be4d26af0fc..a84bacd3d4f 100644 --- a/lib/gitlab/markdown/reference_filter.rb +++ b/lib/gitlab/markdown/reference_filter.rb @@ -25,12 +25,18 @@ module Gitlab ERB::Util.html_escape_once(html) end - # Don't look for references in text nodes that are children of these - # elements. - IGNORE_PARENTS = %w(pre code a style).to_set + def ignore_parents + @ignore_parents ||= begin + # Don't look for references in text nodes that are children of these + # elements. + parents = %w(pre code a style) + parents << 'blockquote' if context[:ignore_blockquotes] + parents.to_set + end + end def ignored_ancestry?(node) - has_ancestor?(node, IGNORE_PARENTS) + has_ancestor?(node, ignore_parents) end def project diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb index 80b8ab8cbcc..e836b05ff25 100644 --- a/lib/gitlab/reference_extractor.rb +++ b/lib/gitlab/reference_extractor.rb @@ -48,7 +48,8 @@ module Gitlab project: project, current_user: current_user, # We don't actually care about the links generated - only_path: true + only_path: true, + ignore_blockquotes: true } pipeline = HTML::Pipeline.new([filter], context) diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index 951e738cb67..f921dd9cc09 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -32,6 +32,10 @@ describe Gitlab::ReferenceExtractor do ``` @bar ``` + + Quote: + + > @offteam }) expect(subject.users).to eq([]) end -- cgit v1.2.1