Fix bug where parsing of emoji was unnecessarily dependent on @project being set
This commit is contained in:
parent
9a4c22d395
commit
ce3fb94939
|
@ -47,7 +47,6 @@ module Gitlab
|
||||||
# Note: reference links will only be generated if @project is set
|
# Note: reference links will only be generated if @project is set
|
||||||
def gfm(text, html_options = {})
|
def gfm(text, html_options = {})
|
||||||
return text if text.nil?
|
return text if text.nil?
|
||||||
return text if @project.nil?
|
|
||||||
|
|
||||||
@html_options = html_options
|
@html_options = html_options
|
||||||
|
|
||||||
|
@ -78,8 +77,11 @@ module Gitlab
|
||||||
#
|
#
|
||||||
# text - Text to parse
|
# text - Text to parse
|
||||||
#
|
#
|
||||||
|
# Note: reference links will only be generated if @project is set
|
||||||
|
#
|
||||||
# Returns parsed text
|
# Returns parsed text
|
||||||
def parse(text)
|
def parse(text)
|
||||||
|
# parse reference links
|
||||||
text.gsub!(REFERENCE_PATTERN) do |match|
|
text.gsub!(REFERENCE_PATTERN) do |match|
|
||||||
prefix = $1 || ''
|
prefix = $1 || ''
|
||||||
reference = $2
|
reference = $2
|
||||||
|
@ -91,8 +93,9 @@ module Gitlab
|
||||||
else
|
else
|
||||||
match
|
match
|
||||||
end
|
end
|
||||||
end
|
end if @project
|
||||||
|
|
||||||
|
# parse emoji
|
||||||
text.gsub!(EMOJI_PATTERN) do |match|
|
text.gsub!(EMOJI_PATTERN) do |match|
|
||||||
if valid_emoji?($2)
|
if valid_emoji?($2)
|
||||||
image_tag("emoji/#{$2}.png", size: "20x20", class: 'emoji', title: $1, alt: $1)
|
image_tag("emoji/#{$2}.png", size: "20x20", class: 'emoji', title: $1, alt: $1)
|
||||||
|
|
|
@ -247,6 +247,11 @@ describe GitlabMarkdownHelper do
|
||||||
it "ignores invalid emoji" do
|
it "ignores invalid emoji" do
|
||||||
gfm(":invalid-emoji:").should_not match(/<img/)
|
gfm(":invalid-emoji:").should_not match(/<img/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should work independet of reference links (i.e. without @project being set)" do
|
||||||
|
@project = nil
|
||||||
|
gfm(":+1:").should match(/<img/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue