From 2b128070cb99c71305eb700d7263ad67f87ea89f Mon Sep 17 00:00:00 2001 From: Deimos Date: Mon, 6 May 2019 23:51:26 -0600 Subject: [PATCH] Add tests for HTML sanitization contexts --- tildes/tests/test_markdown.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tildes/tests/test_markdown.py b/tildes/tests/test_markdown.py index e633d17..de807e3 100644 --- a/tildes/tests/test_markdown.py +++ b/tildes/tests/test_markdown.py @@ -3,6 +3,7 @@ from bs4 import BeautifulSoup +from tildes.enums import BleachContext from tildes.lib.markdown import convert_markdown_to_safe_html @@ -389,3 +390,19 @@ def test_image_syntax_ignored(): assert "! tag by default.""" + markdown = 'Link' + processed = convert_markdown_to_safe_html(markdown) + + assert "rel=" not in processed + + +def test_a_rel_kept_user_bio_context(): + """Ensure a rel= attr is kept on an tag in the user bio context.""" + markdown = 'Link' + processed = convert_markdown_to_safe_html(markdown, BleachContext.USER_BIO) + + assert "rel=" in processed