##// END OF EJS Templates
Fixed: inline code with less-then/greater-than produces @lt; and @gt; (#1416)....
Jean-Philippe Lang -
r3453:054ff0db8ee7
parent child
Show More
@@ -613,7 +613,7 class RedCloth3 < String
613 text.gsub!( CODE_RE ) do |m|
613 text.gsub!( CODE_RE ) do |m|
614 before,lang,code,after = $~[1..4]
614 before,lang,code,after = $~[1..4]
615 lang = " lang=\"#{ lang }\"" if lang
615 lang = " lang=\"#{ lang }\"" if lang
616 rip_offtags( "#{ before }<code#{ lang }>#{ code }</code>#{ after }" )
616 rip_offtags( "#{ before }<code#{ lang }>#{ code }</code>#{ after }", false )
617 end
617 end
618 end
618 end
619
619
@@ -1054,7 +1054,7 class RedCloth3 < String
1054 end
1054 end
1055 end
1055 end
1056
1056
1057 def rip_offtags( text )
1057 def rip_offtags( text, escape_aftertag=true )
1058 if text =~ /<.*>/
1058 if text =~ /<.*>/
1059 ## strip and encode <pre> content
1059 ## strip and encode <pre> content
1060 codepre, used_offtags = 0, {}
1060 codepre, used_offtags = 0, {}
@@ -1068,7 +1068,7 class RedCloth3 < String
1068 @pre_list.last << line
1068 @pre_list.last << line
1069 line = ""
1069 line = ""
1070 else
1070 else
1071 htmlesc( aftertag, :NoQuotes ) if aftertag
1071 htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag
1072 line = "<redpre##{ @pre_list.length }>"
1072 line = "<redpre##{ @pre_list.length }>"
1073 $3.match(/<#{ OFFTAGS }([^>]*)>/)
1073 $3.match(/<#{ OFFTAGS }([^>]*)>/)
1074 tag = $1
1074 tag = $1
@@ -60,4 +60,23 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
60 end
60 end
61 end
61 end
62 end
62 end
63
64 def test_inline_code
65 to_test = {
66 'this is @some code@' => 'this is <code>some code</code>',
67 '@<Location /redmine>@' => '<code>&lt;Location /redmine&gt;</code>',
68 }
69 to_test.each do |text, expected|
70 assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html
71 end
72 end
73
74 def test_escaping
75 to_test = {
76 'this is a <script>' => 'this is a &lt;script&gt;',
77 }
78 to_test.each do |text, expected|
79 assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html
80 end
81 end
63 end
82 end
General Comments 0
You need to be logged in to leave comments. Login now