Commit ce3fb949398786c9cc9c9d7803b72cb57f661279

Authored by Riyad Preukschas
1 parent 9a4c22d3

Fix bug where parsing of emoji was unnecessarily dependent on @project being set

lib/gitlab/markdown.rb
... ... @@ -47,7 +47,6 @@ module Gitlab
47 47 # Note: reference links will only be generated if @project is set
48 48 def gfm(text, html_options = {})
49 49 return text if text.nil?
50   - return text if @project.nil?
51 50  
52 51 @html_options = html_options
53 52  
... ... @@ -78,8 +77,11 @@ module Gitlab
78 77 #
79 78 # text - Text to parse
80 79 #
  80 + # Note: reference links will only be generated if @project is set
  81 + #
81 82 # Returns parsed text
82 83 def parse(text)
  84 + # parse reference links
83 85 text.gsub!(REFERENCE_PATTERN) do |match|
84 86 prefix = $1 || ''
85 87 reference = $2
... ... @@ -91,8 +93,9 @@ module Gitlab
91 93 else
92 94 match
93 95 end
94   - end
  96 + end if @project
95 97  
  98 + # parse emoji
96 99 text.gsub!(EMOJI_PATTERN) do |match|
97 100 if valid_emoji?($2)
98 101 image_tag("emoji/#{$2}.png", size: "20x20", class: 'emoji', title: $1, alt: $1)
... ...
spec/helpers/gitlab_markdown_helper_spec.rb
... ... @@ -247,6 +247,11 @@ describe GitlabMarkdownHelper do
247 247 it "ignores invalid emoji" do
248 248 gfm(":invalid-emoji:").should_not match(/<img/)
249 249 end
  250 +
  251 + it "should work independet of reference links (i.e. without @project being set)" do
  252 + @project = nil
  253 + gfm(":+1:").should match(/<img/)
  254 + end
250 255 end
251 256 end
252 257  
... ...