Skip to content

Commit

Permalink
Use "strip" in bleach
Browse files Browse the repository at this point in the history
This removes forbidden html, rather than leaving them in place but
unrendered.
  • Loading branch information
mouse-reeve committed Jul 4, 2022
1 parent 70beb24 commit 9d9b7f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bookwyrm/tests/test_sanitize_html.py
Expand Up @@ -32,14 +32,14 @@ def test_valid_html_invalid_attrs(self):
self.assertEqual(output, '<a href="fish.com">yes </a> <i>html</i>')

def test_invalid_html(self):
"""remove all html when the html is malformed"""
"""don't allow malformed html"""
input_text = "<b>yes <i>html</i>"
output = clean(input_text)
self.assertEqual("yes html", output)
self.assertEqual("<b>yes <i>html</i></b>", output)

input_text = "yes <i></b>html </i>"
output = clean(input_text)
self.assertEqual("yes html ", output)
self.assertEqual("yes <i>html </i>", output)

def test_disallowed_html(self):
"""remove disallowed html but keep allowed html"""
Expand Down
1 change: 1 addition & 0 deletions bookwyrm/utils/sanitizer.py
Expand Up @@ -22,4 +22,5 @@ def clean(input_text):
"li",
],
attributes=["href", "rel", "src", "alt"],
strip=True,
)

0 comments on commit 9d9b7f3

Please sign in to comment.