OSDN Git Service

dont escape images inside links for gfm. Fixes #2701
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 29 Jan 2013 09:00:56 +0000 (11:00 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 29 Jan 2013 09:00:56 +0000 (11:00 +0200)
app/helpers/gitlab_markdown_helper.rb

index 111982e..1a3d34e 100644 (file)
@@ -13,7 +13,13 @@ module GitlabMarkdownHelper
   def link_to_gfm(body, url, html_options = {})
     return "" if body.blank?
 
-    gfm_body = gfm(escape_once(body), html_options)
+    escaped_body = if body =~ /^\<img/
+                     body
+                   else
+                     escape_once(body)
+                   end
+
+    gfm_body = gfm(escaped_body, html_options)
 
     gfm_body.gsub!(%r{<a.*?>.*?</a>}m) do |match|
       "</a>#{match}#{link_to("", url, html_options)[0..-5]}" # "</a>".length +1