Browse code

Escapes double quotes in img tag

Frederic Hemberger authored on 26/09/2011 at 09:54:45
Showing 1 changed files
... ...
@@ -26,11 +26,11 @@ module Jekyll
26 26
 
27 27
       if markup =~ /(?<class>\S.*\s+)?(?<src>(?:https?:\/\/|\/|\S+\/)\S+)(?:\s+(?<width>\d+))?(?:\s+(?<height>\d+))?(?<title>\s+.+)?/i
28 28
         @img = attributes.reduce({}) { |img, attr| img[attr] = $~[attr].strip if $~[attr]; img }
29
-        if @img['title'] =~ /(?:"|')([^"']+)?(?:"|')\s+(?:"|')([^"']+)?(?:"|')/
30
-          @img['title']  = $1
31
-          @img['alt']    = $2
29
+        if /(?:"|')(?<title>[^"']+)?(?:"|')\s+(?:"|')(?<alt>[^"']+)?(?:"|')/ =~ @img['title']
30
+          @img['title']  = title
31
+          @img['alt']    = alt
32 32
         else
33
-          @img['alt']    = @img['title'].gsub!(/"/, '')
33
+          @img['alt']    = @img['title'].gsub!(/"/, '&#34;')
34 34
         end
35 35
         @img['class'].gsub!(/"/, '')
36 36
       end