Better guard against nil projects in ReferenceFilter
This commit is contained in:
parent
9eaaa7cdef
commit
31172475d2
2 changed files with 7 additions and 2 deletions
|
@ -25,7 +25,8 @@ module Gitlab
|
||||||
ISSUE_PATTERN = /(?<issue>([A-Z\-]+-)\d+)/
|
ISSUE_PATTERN = /(?<issue>([A-Z\-]+-)\d+)/
|
||||||
|
|
||||||
def call
|
def call
|
||||||
return doc if project.default_issues_tracker?
|
# Early return if the project isn't using an external tracker
|
||||||
|
return doc if project.nil? || project.default_issues_tracker?
|
||||||
|
|
||||||
replace_text_nodes_matching(ISSUE_PATTERN) do |content|
|
replace_text_nodes_matching(ISSUE_PATTERN) do |content|
|
||||||
issue_link_filter(content)
|
issue_link_filter(content)
|
||||||
|
|
|
@ -42,10 +42,11 @@ module Gitlab
|
||||||
#
|
#
|
||||||
# Returns the updated Nokogiri::XML::Document object.
|
# Returns the updated Nokogiri::XML::Document object.
|
||||||
def replace_text_nodes_matching(pattern)
|
def replace_text_nodes_matching(pattern)
|
||||||
|
return doc if project.nil?
|
||||||
|
|
||||||
doc.search('text()').each do |node|
|
doc.search('text()').each do |node|
|
||||||
content = node.to_html
|
content = node.to_html
|
||||||
|
|
||||||
next if project.nil?
|
|
||||||
next unless content.match(pattern)
|
next unless content.match(pattern)
|
||||||
next if ignored_ancestry?(node)
|
next if ignored_ancestry?(node)
|
||||||
|
|
||||||
|
@ -59,6 +60,9 @@ module Gitlab
|
||||||
doc
|
doc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Ensure that a :project key exists in context
|
||||||
|
#
|
||||||
|
# Note that while the key might exist, its value could be nil!
|
||||||
def validate
|
def validate
|
||||||
needs :project
|
needs :project
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue