From ce3fb949398786c9cc9c9d7803b72cb57f661279 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sat, 8 Sep 2012 00:49:17 +0200 Subject: [PATCH] Fix bug where parsing of emoji was unnecessarily dependent on @project being set --- lib/gitlab/markdown.rb | 7 +++++-- spec/helpers/gitlab_markdown_helper_spec.rb | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index afb61364b1f..f9125e0390a 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -47,7 +47,6 @@ module Gitlab # Note: reference links will only be generated if @project is set def gfm(text, html_options = {}) return text if text.nil? - return text if @project.nil? @html_options = html_options @@ -78,8 +77,11 @@ module Gitlab # # text - Text to parse # + # Note: reference links will only be generated if @project is set + # # Returns parsed text def parse(text) + # parse reference links text.gsub!(REFERENCE_PATTERN) do |match| prefix = $1 || '' reference = $2 @@ -91,8 +93,9 @@ module Gitlab else match end - end + end if @project + # parse emoji text.gsub!(EMOJI_PATTERN) do |match| if valid_emoji?($2) image_tag("emoji/#{$2}.png", size: "20x20", class: 'emoji', title: $1, alt: $1) diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index 3e7a02c6e35..4dd3802a5c1 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -247,6 +247,11 @@ describe GitlabMarkdownHelper do it "ignores invalid emoji" do gfm(":invalid-emoji:").should_not match(/