summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/redcloth3.rb6
-rw-r--r--test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb19
2 files changed, 22 insertions, 3 deletions
diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb
index 1e3d31ab1..2470fa5a9 100644
--- a/lib/redcloth3.rb
+++ b/lib/redcloth3.rb
@@ -613,7 +613,7 @@ class RedCloth3 < String
text.gsub!( CODE_RE ) do |m|
before,lang,code,after = $~[1..4]
lang = " lang=\"#{ lang }\"" if lang
- rip_offtags( "#{ before }<code#{ lang }>#{ code }</code>#{ after }" )
+ rip_offtags( "#{ before }<code#{ lang }>#{ code }</code>#{ after }", false )
end
end
@@ -1054,7 +1054,7 @@ class RedCloth3 < String
end
end
- def rip_offtags( text )
+ def rip_offtags( text, escape_aftertag=true )
if text =~ /<.*>/
## strip and encode <pre> content
codepre, used_offtags = 0, {}
@@ -1068,7 +1068,7 @@ class RedCloth3 < String
@pre_list.last << line
line = ""
else
- htmlesc( aftertag, :NoQuotes ) if aftertag
+ htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag
line = "<redpre##{ @pre_list.length }>"
$3.match(/<#{ OFFTAGS }([^>]*)>/)
tag = $1
diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
index 8cb98ba51..66e588ffb 100644
--- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
@@ -60,4 +60,23 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
end
end
end
+
+ def test_inline_code
+ to_test = {
+ 'this is @some code@' => 'this is <code>some code</code>',
+ '@<Location /redmine>@' => '<code>&lt;Location /redmine&gt;</code>',
+ }
+ to_test.each do |text, expected|
+ assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html
+ end
+ end
+
+ def test_escaping
+ to_test = {
+ 'this is a <script>' => 'this is a &lt;script&gt;',
+ }
+ to_test.each do |text, expected|
+ assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html
+ end
+ end
end