Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
6027e14f4b73
Commit
31172475
authored
Apr 15, 2015
by
Robert Speicher
Browse files
Better guard against nil projects in ReferenceFilter
parent
ebe980b48136
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/gitlab/markdown/external_issue_reference_filter.rb
View file @
6027e14f
...
...
@@ -25,7 +25,8 @@ def self.references_in(text)
ISSUE_PATTERN
=
/(?<issue>([A-Z\-]+-)\d+)/
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
|
issue_link_filter
(
content
)
...
...
lib/gitlab/markdown/reference_filter.rb
View file @
6027e14f
...
...
@@ -42,10 +42,11 @@ def reference_class(type)
#
# Returns the updated Nokogiri::XML::Document object.
def
replace_text_nodes_matching
(
pattern
)
return
doc
if
project
.
nil?
doc
.
search
(
'text()'
).
each
do
|
node
|
content
=
node
.
to_html
next
if
project
.
nil?
next
unless
content
.
match
(
pattern
)
next
if
ignored_ancestry?
(
node
)
...
...
@@ -59,6 +60,9 @@ def replace_text_nodes_matching(pattern)
doc
end
# Ensure that a :project key exists in context
#
# Note that while the key might exist, its value could be nil!
def
validate
needs
:project
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment