Feature #20511 ยป 20511.patch
lib/redmine/wiki_formatting/textile/redcloth3.rb | ||
---|---|---|
298 | 298 |
@pre_list = [] |
299 | 299 |
rip_offtags text |
300 | 300 |
no_textile text |
301 |
clean_html_comment text |
|
301 | 302 |
escape_html_tags text |
302 | 303 |
# need to do this before #hard_break and #blocks |
303 | 304 |
block_textile_quotes text unless @lite_mode |
... | ... | |
1217 | 1218 |
end |
1218 | 1219 |
end |
1219 | 1220 |
end |
1221 | ||
1222 |
def clean_html_comment(text) |
|
1223 |
text.gsub!(/<!--[\s\S]*?-->/, '') |
|
1224 |
end |
|
1220 | 1225 |
end |
test/helpers/application_helper_test.rb | ||
---|---|---|
1300 | 1300 |
"<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>", |
1301 | 1301 |
"<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>", |
1302 | 1302 |
"<pre><div>content</div></pre>" => "<pre><div>content</div></pre>", |
1303 |
"HTML comment: <!-- no comments -->" => "<p>HTML comment: <!-- no comments --></p>", |
|
1304 | 1303 |
"<!-- opening comment" => "<p><!-- opening comment</p>", |
1305 | 1304 |
# remove attributes including class |
1306 | 1305 |
"<pre class='foo'>some text</pre>" => "<pre>some text</pre>", |
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb | ||
---|---|---|
719 | 719 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '') |
720 | 720 |
end |
721 | 721 | |
722 |
def test_should_clean_html_comment |
|
723 |
text = <<~STR |
|
724 |
<!-- begin --> |
|
725 |
Hello <!-- comment between words -->world. |
|
726 | ||
727 |
<!-- |
|
728 |
multi-line |
|
729 |
comment -->Foo |
|
730 | ||
731 |
<pre> |
|
732 |
This is a code block. |
|
733 |
<p> |
|
734 |
<!-- comments in a code block should be preserved --> |
|
735 |
</p> |
|
736 |
</pre> |
|
737 |
STR |
|
738 |
expected = <<~EXPECTED |
|
739 |
<p>Hello world.</p> |
|
740 | ||
741 |
<p>Foo</p> |
|
742 | ||
743 |
<pre> |
|
744 |
This is a code block. |
|
745 |
<p> |
|
746 |
<!-- comments in a code block should be preserved --> |
|
747 |
</p> |
|
748 |
</pre> |
|
749 | ||
750 |
EXPECTED |
|
751 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '') |
|
752 |
end |
|
753 | ||
722 | 754 |
private |
723 | 755 | |
724 | 756 |
def assert_html_output(to_test, expect_paragraph = true) |