summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-12 18:50:55 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-12 18:50:55 +0000
commit7a01d0cc74eac15475f4c2245447c7f751744219 (patch)
tree29653aeb070b545e0cde107377f71d2bb2da6fbf /lib
parentb09fd2337a20e7d45cb9ef6ac1f4dde0d0e43e2a (diff)
parentfc2adfb6e4af59e45809661e32be0d2ad3158503 (diff)
downloadgitlab-ce-7a01d0cc74eac15475f4c2245447c7f751744219.tar.gz
Merge branch 'bug_with_apostrophe' into 'master'
Bug with apostrophe when at mentioning users This fixes the situation where mentioning user with apostrophe at the end causes a link to issue 39 if the project has that issue, so `@marin` would look like `@marin&#39;s`. Fixes #1034 See merge request !1165
Diffstat (limited to 'lib')
-rw-r--r--lib/redcarpet/render/gitlab_html.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb
index c3378d6a18f..54d740908d5 100644
--- a/lib/redcarpet/render/gitlab_html.rb
+++ b/lib/redcarpet/render/gitlab_html.rb
@@ -10,6 +10,17 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
super options
end
+ # If project has issue number 39, apostrophe will be linked in
+ # regular text to the issue as Redcarpet will convert apostrophe to
+ # #39;
+ # We replace apostrophe with right single quote before Redcarpet
+ # does the processing and put the apostrophe back in postprocessing.
+ # This only influences regular text, code blocks are untouched.
+ def normal_text(text)
+ return text unless text.present?
+ text.gsub("'", "&rsquo;")
+ end
+
def block_code(code, language)
# New lines are placed to fix an rendering issue
# with code wrapped inside <h1> tag for next case:
@@ -44,6 +55,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
end
def postprocess(full_document)
+ full_document.gsub!("&rsquo;", "'")
unless @template.instance_variable_get("@project_wiki") || @project.nil?
full_document = h.create_relative_links(full_document)
end