From 19a646b5e9e5f294896afc7552a4941933b8fb22 Mon Sep 17 00:00:00 2001 From: Frederic Hemberger Date: Mon, 26 Sep 2011 11:54:45 +0200 Subject: [PATCH] Escapes double quotes in img tag --- plugins/image_tag.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/image_tag.rb b/plugins/image_tag.rb index 92e2176..20595cb 100644 --- a/plugins/image_tag.rb +++ b/plugins/image_tag.rb @@ -26,11 +26,11 @@ module Jekyll if markup =~ /(?\S.*\s+)?(?(?:https?:\/\/|\/|\S+\/)\S+)(?:\s+(?\d+))?(?:\s+(?\d+))?(?\s+.+)?/i @img = attributes.reduce({}) { |img, attr| img[attr] = $~[attr].strip if $~[attr]; img } - if @img['title'] =~ /(?:"|')([^"']+)?(?:"|')\s+(?:"|')([^"']+)?(?:"|')/ - @img['title'] = $1 - @img['alt'] = $2 + if /(?:"|')(?<title>[^"']+)?(?:"|')\s+(?:"|')(?<alt>[^"']+)?(?:"|')/ =~ @img['title'] + @img['title'] = title + @img['alt'] = alt else - @img['alt'] = @img['title'].gsub!(/"/, '') + @img['alt'] = @img['title'].gsub!(/"/, '"') end @img['class'].gsub!(/"/, '') end