Ignore references in blockquotes.
This commit is contained in:
parent
fe78984f20
commit
94919c7ef6
3 changed files with 16 additions and 5 deletions
|
@ -25,12 +25,18 @@ module Gitlab
|
||||||
ERB::Util.html_escape_once(html)
|
ERB::Util.html_escape_once(html)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Don't look for references in text nodes that are children of these
|
def ignore_parents
|
||||||
# elements.
|
@ignore_parents ||= begin
|
||||||
IGNORE_PARENTS = %w(pre code a style).to_set
|
# 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)
|
def ignored_ancestry?(node)
|
||||||
has_ancestor?(node, IGNORE_PARENTS)
|
has_ancestor?(node, ignore_parents)
|
||||||
end
|
end
|
||||||
|
|
||||||
def project
|
def project
|
||||||
|
|
|
@ -48,7 +48,8 @@ module Gitlab
|
||||||
project: project,
|
project: project,
|
||||||
current_user: current_user,
|
current_user: current_user,
|
||||||
# We don't actually care about the links generated
|
# We don't actually care about the links generated
|
||||||
only_path: true
|
only_path: true,
|
||||||
|
ignore_blockquotes: true
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline = HTML::Pipeline.new([filter], context)
|
pipeline = HTML::Pipeline.new([filter], context)
|
||||||
|
|
|
@ -32,6 +32,10 @@ describe Gitlab::ReferenceExtractor do
|
||||||
```
|
```
|
||||||
@bar
|
@bar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Quote:
|
||||||
|
|
||||||
|
> @offteam
|
||||||
})
|
})
|
||||||
expect(subject.users).to eq([])
|
expect(subject.users).to eq([])
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue