From: Jean-Philippe Lang Date: Sun, 13 Apr 2008 12:45:17 +0000 (+0000) Subject: Replace closing html tags with html entity (#910). X-Git-Tag: 0.8.0-RC1~585 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=97fe797ad36389ea4719e90677408d9eed0cb369;p=redmine.git Replace closing html tags with html entity (#910). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1348 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/lib/redcloth.rb b/lib/redcloth.rb index 5ed23b8f7..7e0c71839 100644 --- a/lib/redcloth.rb +++ b/lib/redcloth.rb @@ -1134,7 +1134,7 @@ class RedCloth < String ALLOWED_TAGS = %w(redpre pre code) def escape_html_tags(text) - text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "<#{$1}" } + text.gsub!(%r{<(\/?(\w+)[^>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "<#{$1}#{'>' if $3}" } end end diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 66499c003..f0de341c6 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -134,8 +134,9 @@ class ApplicationHelperTest < HelperTestCase def test_html_tags to_test = { - "
content
" => "

<div>content</div>

", - "" => "

<script>some script;</script>

", + "
content
" => "

<div>content</div>

", + "
content
" => "

<div class=\"bold\">content</div>

", + "" => "

<script>some script;</script>

", # do not escape pre/code tags "
\nline 1\nline2
" => "
\nline 1\nline2
", "
\nline 1\nline2
" => "
\nline 1\nline2
",