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