@@ -613,7 +613,7 class RedCloth3 < String | |||
|
613 | 613 | text.gsub!( CODE_RE ) do |m| |
|
614 | 614 | before,lang,code,after = $~[1..4] |
|
615 | 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 | 617 | end |
|
618 | 618 | end |
|
619 | 619 | |
@@ -1054,7 +1054,7 class RedCloth3 < String | |||
|
1054 | 1054 | end |
|
1055 | 1055 | end |
|
1056 | 1056 | |
|
1057 | def rip_offtags( text ) | |
|
1057 | def rip_offtags( text, escape_aftertag=true ) | |
|
1058 | 1058 | if text =~ /<.*>/ |
|
1059 | 1059 | ## strip and encode <pre> content |
|
1060 | 1060 | codepre, used_offtags = 0, {} |
@@ -1068,7 +1068,7 class RedCloth3 < String | |||
|
1068 | 1068 | @pre_list.last << line |
|
1069 | 1069 | line = "" |
|
1070 | 1070 | else |
|
1071 | htmlesc( aftertag, :NoQuotes ) if aftertag | |
|
1071 | htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag | |
|
1072 | 1072 | line = "<redpre##{ @pre_list.length }>" |
|
1073 | 1073 | $3.match(/<#{ OFFTAGS }([^>]*)>/) |
|
1074 | 1074 | tag = $1 |
@@ -60,4 +60,23 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase | |||
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 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><Location /redmine></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 <script>', | |
|
77 | } | |
|
78 | to_test.each do |text, expected| | |
|
79 | assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html | |
|
80 | end | |
|
81 | end | |
|
63 | 82 | end |
General Comments 0
You need to be logged in to leave comments.
Login now