Commit ce3fb949398786c9cc9c9d7803b72cb57f661279
1 parent
9a4c22d3
Exists in
master
and in
4 other branches
Fix bug where parsing of emoji was unnecessarily dependent on @project being set
Showing
2 changed files
with
10 additions
and
2 deletions
Show diff stats
lib/gitlab/markdown.rb
| @@ -47,7 +47,6 @@ module Gitlab | @@ -47,7 +47,6 @@ module Gitlab | ||
| 47 | # Note: reference links will only be generated if @project is set | 47 | # Note: reference links will only be generated if @project is set |
| 48 | def gfm(text, html_options = {}) | 48 | def gfm(text, html_options = {}) |
| 49 | return text if text.nil? | 49 | return text if text.nil? |
| 50 | - return text if @project.nil? | ||
| 51 | 50 | ||
| 52 | @html_options = html_options | 51 | @html_options = html_options |
| 53 | 52 | ||
| @@ -78,8 +77,11 @@ module Gitlab | @@ -78,8 +77,11 @@ module Gitlab | ||
| 78 | # | 77 | # |
| 79 | # text - Text to parse | 78 | # text - Text to parse |
| 80 | # | 79 | # |
| 80 | + # Note: reference links will only be generated if @project is set | ||
| 81 | + # | ||
| 81 | # Returns parsed text | 82 | # Returns parsed text |
| 82 | def parse(text) | 83 | def parse(text) |
| 84 | + # parse reference links | ||
| 83 | text.gsub!(REFERENCE_PATTERN) do |match| | 85 | text.gsub!(REFERENCE_PATTERN) do |match| |
| 84 | prefix = $1 || '' | 86 | prefix = $1 || '' |
| 85 | reference = $2 | 87 | reference = $2 |
| @@ -91,8 +93,9 @@ module Gitlab | @@ -91,8 +93,9 @@ module Gitlab | ||
| 91 | else | 93 | else |
| 92 | match | 94 | match |
| 93 | end | 95 | end |
| 94 | - end | 96 | + end if @project |
| 95 | 97 | ||
| 98 | + # parse emoji | ||
| 96 | text.gsub!(EMOJI_PATTERN) do |match| | 99 | text.gsub!(EMOJI_PATTERN) do |match| |
| 97 | if valid_emoji?($2) | 100 | if valid_emoji?($2) |
| 98 | image_tag("emoji/#{$2}.png", size: "20x20", class: 'emoji', title: $1, alt: $1) | 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,6 +247,11 @@ describe GitlabMarkdownHelper do | ||
| 247 | it "ignores invalid emoji" do | 247 | it "ignores invalid emoji" do |
| 248 | gfm(":invalid-emoji:").should_not match(/<img/) | 248 | gfm(":invalid-emoji:").should_not match(/<img/) |
| 249 | end | 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 | end | 255 | end |
| 251 | end | 256 | end |
| 252 | 257 |