Index: lib/redcloth3.rb =================================================================== --- lib/redcloth3.rb (revision 5097) +++ lib/redcloth3.rb (working copy) @@ -707,11 +707,13 @@ atts = pba( atts ) # pass to prefix handler + replacement = nil if respond_to? "textile_#{ tag }", true - text.gsub!( $&, method( "textile_#{ tag }" ).call( tag, atts, cite, content ) ) + replacement = method( "textile_#{ tag }" ).call( tag, atts, cite, content ) elsif respond_to? "textile_#{ tagpre }_", true - text.gsub!( $&, method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) ) + replacement = method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) end + text.gsub!( $& ) { replacement } if replacement end end Index: test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb =================================================================== --- test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb (revision 5096) +++ test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb (working copy) @@ -64,12 +64,18 @@ '@@' => '<Location /redmine>' ) end - + def test_escaping assert_html_output( 'this is a