mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 12:59:17 +02:00
Fix #923: Use same markdown widget for all content fields (rules, description, reports, notes, etc.)
This commit is contained in:
parent
8d29adf6be
commit
7850ca3e1c
12 changed files with 128 additions and 75 deletions
|
@ -103,27 +103,40 @@ def test_join_url(start, end, expected):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"text, content_type, expected",
|
||||
"text, content_type, permissive, expected",
|
||||
[
|
||||
("hello world", "text/markdown", "<p>hello world</p>"),
|
||||
("hello world", "text/plain", "<p>hello world</p>"),
|
||||
("<strong>hello world</strong>", "text/html", "<strong>hello world</strong>"),
|
||||
("hello world", "text/markdown", False, "<p>hello world</p>"),
|
||||
("hello world", "text/plain", False, "<p>hello world</p>"),
|
||||
(
|
||||
"<strong>hello world</strong>",
|
||||
"text/html",
|
||||
False,
|
||||
"<strong>hello world</strong>",
|
||||
),
|
||||
# images and other non whitelisted html should be removed
|
||||
("hello world\n", "text/markdown", "<p>hello world</p>"),
|
||||
("hello world\n", "text/markdown", False, "<p>hello world</p>"),
|
||||
(
|
||||
"hello world\n\n<script></script>\n\n<style></style>",
|
||||
"text/markdown",
|
||||
False,
|
||||
"<p>hello world</p>",
|
||||
),
|
||||
(
|
||||
"<p>hello world</p><script></script>\n\n<style></style>",
|
||||
"text/html",
|
||||
False,
|
||||
"<p>hello world</p>",
|
||||
),
|
||||
(
|
||||
'<p class="foo">hello world</p><script></script>\n\n<style></style>',
|
||||
"text/markdown",
|
||||
True,
|
||||
'<p class="foo">hello world</p>',
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_render_html(text, content_type, expected):
|
||||
result = utils.render_html(text, content_type)
|
||||
def test_render_html(text, content_type, permissive, expected):
|
||||
result = utils.render_html(text, content_type, permissive=permissive)
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue