Browse Source

Add tests for HTML sanitization contexts

merge-requests/69/head
Deimos 6 years ago
parent
commit
2b128070cb
  1. 17
      tildes/tests/test_markdown.py

17
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 "!<a" in processed
assert "img" not in processed
def test_a_rel_removed_default_context():
"""Ensure a rel= attr is removed from an <a> tag by default."""
markdown = '<a href="http://example.com" rel="something">Link</a>'
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 <a> tag in the user bio context."""
markdown = '<a href="http://example.com" rel="something">Link</a>'
processed = convert_markdown_to_safe_html(markdown, BleachContext.USER_BIO)
assert "rel=" in processed
Loading…
Cancel
Save