Feature #20511 ยป 20511.patch
| lib/redmine/wiki_formatting/textile/redcloth3.rb | ||
|---|---|---|
|
@pre_list = []
|
||
|
rip_offtags text
|
||
|
no_textile text
|
||
|
clean_html_comment text
|
||
|
escape_html_tags text
|
||
|
# need to do this before #hard_break and #blocks
|
||
|
block_textile_quotes text unless @lite_mode
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
end
|
||
|
def clean_html_comment(text)
|
||
|
text.gsub!(/<!--[\s\S]*?-->/, '')
|
||
|
end
|
||
|
end
|
||
| test/helpers/application_helper_test.rb | ||
|---|---|---|
|
"<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><div>content</div></pre>" => "<pre><div>content</div></pre>",
|
||
|
"HTML comment: <!-- no comments -->" => "<p>HTML comment: <!-- no comments --></p>",
|
||
|
"<!-- opening comment" => "<p><!-- opening comment</p>",
|
||
|
# remove attributes including class
|
||
|
"<pre class='foo'>some text</pre>" => "<pre>some text</pre>",
|
||
| test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb | ||
|---|---|---|
|
assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '')
|
||
|
end
|
||
|
def test_should_clean_html_comment
|
||
|
text = <<~STR
|
||
|
<!-- begin -->
|
||
|
Hello <!-- comment between words -->world.
|
||
|
<!--
|
||
|
multi-line
|
||
|
comment -->Foo
|
||
|
<pre>
|
||
|
This is a code block.
|
||
|
<p>
|
||
|
<!-- comments in a code block should be preserved -->
|
||
|
</p>
|
||
|
</pre>
|
||
|
STR
|
||
|
expected = <<~EXPECTED
|
||
|
<p>Hello world.</p>
|
||
|
<p>Foo</p>
|
||
|
<pre>
|
||
|
This is a code block.
|
||
|
<p>
|
||
|
<!-- comments in a code block should be preserved -->
|
||
|
</p>
|
||
|
</pre>
|
||
|
EXPECTED
|
||
|
assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '')
|
||
|
end
|
||
|
private
|
||
|
def assert_html_output(to_test, expect_paragraph = true)
|
||