diff --git a/lib/redcloth.rb b/lib/redcloth.rb
index 4faa4b9e5..421346cc7 100644
--- a/lib/redcloth.rb
+++ b/lib/redcloth.rb
@@ -465,7 +465,7 @@ class RedCloth < String
style << "vertical-align:#{ v_align( $& ) };" if text =~ A_VLGN
end
- style << "#{ $1 };" if not filter_styles and
+ style << "#{ htmlesc $1 };" if not filter_styles and
text.sub!( /\{([^}]*)\}/, '' )
lang = $1 if
@@ -786,7 +786,7 @@ class RedCloth < String
atts = pba( atts )
atts = " href=\"#{ url }#{ slash }\"#{ atts }"
- atts << " title=\"#{ title }\"" if title
+ atts << " title=\"#{ htmlesc title }\"" if title
atts = shelve( atts ) if atts
external = (url =~ /^https?:\/\//) ? ' class="external"' : ''
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index e20866786..04449d921 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -61,6 +61,7 @@ class ApplicationHelperTest < HelperTestCase
'This is a "link":http://foo.bar' => 'This is a link',
'This is an intern "link":/foo/bar' => 'This is an intern link',
'"link (Link title)":http://foo.bar' => 'link',
+ '"link (Link title with "double-quotes")":http://foo.bar' => 'link',
# no multiline link text
"This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line
\nand another on a second line\":test"
}