diff --git a/bookwyrm/sanitize_html.py b/bookwyrm/sanitize_html.py index 538264fc..4edd2818 100644 --- a/bookwyrm/sanitize_html.py +++ b/bookwyrm/sanitize_html.py @@ -22,9 +22,7 @@ class InputHtmlParser(HTMLParser): # pylint: disable=abstract-method "ol", "li", ] - self.allowed_attrs = [ - "href", "rel", "src", "alt" - ] + self.allowed_attrs = ["href", "rel", "src", "alt"] self.tag_stack = [] self.output = [] # if the html appears invalid, we just won't allow any at all @@ -36,7 +34,7 @@ class InputHtmlParser(HTMLParser): # pylint: disable=abstract-method allowed_attrs = " ".join( f'{a}="{v}"' for a, v in attrs if a in self.allowed_attrs ) - reconstructed = f'<{tag}' + reconstructed = f"<{tag}" if allowed_attrs: reconstructed += " " + allowed_attrs reconstructed += ">" diff --git a/bookwyrm/tests/test_sanitize_html.py b/bookwyrm/tests/test_sanitize_html.py index 572f8332..5814f220 100644 --- a/bookwyrm/tests/test_sanitize_html.py +++ b/bookwyrm/tests/test_sanitize_html.py @@ -37,10 +37,7 @@ class Sanitizer(TestCase): parser = InputHtmlParser() parser.feed(input_text) output = parser.get_output() - self.assertEqual( - output, - 'yes html' - ) + self.assertEqual(output, 'yes html') def test_invalid_html(self): """remove all html when the html is malformed"""