Replace closing html tags with html entity (#910).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1348 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8b9fb29d95
commit
97fe797ad3
|
@ -1134,7 +1134,7 @@ class RedCloth < String
|
||||||
ALLOWED_TAGS = %w(redpre pre code)
|
ALLOWED_TAGS = %w(redpre pre code)
|
||||||
|
|
||||||
def escape_html_tags(text)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -134,8 +134,9 @@ class ApplicationHelperTest < HelperTestCase
|
||||||
|
|
||||||
def test_html_tags
|
def test_html_tags
|
||||||
to_test = {
|
to_test = {
|
||||||
"<div>content</div>" => "<p><div>content</div></p>",
|
"<div>content</div>" => "<p><div>content</div></p>",
|
||||||
"<script>some script;</script>" => "<p><script>some script;</script></p>",
|
"<div class=\"bold\">content</div>" => "<p><div class=\"bold\">content</div></p>",
|
||||||
|
"<script>some script;</script>" => "<p><script>some script;</script></p>",
|
||||||
# do not escape pre/code tags
|
# do not escape pre/code tags
|
||||||
"<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>",
|
"<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>",
|
||||||
"<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>",
|
"<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>",
|
||||||
|
|
Loading…
Reference in New Issue