@@ -435,13 +435,16 class RedCloth3 < String | |||
|
435 | 435 | # |
|
436 | 436 | # Flexible HTML escaping |
|
437 | 437 | # |
|
438 | def htmlesc( str, mode ) | |
|
438 | def htmlesc( str, mode=:Quotes ) | |
|
439 | if str | |
|
439 | 440 | str.gsub!( '&', '&' ) |
|
440 | 441 | str.gsub!( '"', '"' ) if mode != :NoQuotes |
|
441 | 442 | str.gsub!( "'", ''' ) if mode == :Quotes |
|
442 | 443 | str.gsub!( '<', '<') |
|
443 | 444 | str.gsub!( '>', '>') |
|
444 | 445 | end |
|
446 | str | |
|
447 | end | |
|
445 | 448 | |
|
446 | 449 | # Search and replace for Textile glyphs (quotes, dashes, other symbols) |
|
447 | 450 | def pgl( text ) |
@@ -914,6 +917,7 class RedCloth3 < String | |||
|
914 | 917 | def inline_textile_image( text ) |
|
915 | 918 | text.gsub!( IMAGE_RE ) do |m| |
|
916 | 919 | stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8] |
|
920 | htmlesc title | |
|
917 | 921 | atts = pba( atts ) |
|
918 | 922 | atts = " src=\"#{ url }\"#{ atts }" |
|
919 | 923 | atts << " title=\"#{ title }\"" if title |
@@ -70,6 +70,8 class ApplicationHelperTest < HelperTestCase | |||
|
70 | 70 | 'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>', |
|
71 | 71 | 'with class !(some-class)http://foo.bar/image.jpg!' => 'with class <img src="http://foo.bar/image.jpg" class="some-class" alt="" />', |
|
72 | 72 | 'with style !{width:100px;height100px}http://foo.bar/image.jpg!' => 'with style <img src="http://foo.bar/image.jpg" style="width:100px;height100px;" alt="" />', |
|
73 | 'with title !http://foo.bar/image.jpg(This is a title)!' => 'with title <img src="http://foo.bar/image.jpg" title="This is a title" alt="This is a title" />', | |
|
74 | 'with title !http://foo.bar/image.jpg(This is a double-quoted "title")!' => 'with title <img src="http://foo.bar/image.jpg" title="This is a double-quoted "title"" alt="This is a double-quoted "title"" />', | |
|
73 | 75 | } |
|
74 | 76 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
75 | 77 | end |
General Comments 0
You need to be logged in to leave comments.
Login now