Skip to content

Commit 0038151

Browse files
authored
fix: Fix removetags (ietf-tools#4226)
I don't think this ever worked.
1 parent dde5ed4 commit 0038151

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

ietf/utils/html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def unescape(text):
3434
def remove_tags(html, tags):
3535
"""Returns the given HTML sanitized, and with the given tags removed."""
3636
allowed = set(acceptable_tags) - set([ t.lower() for t in tags ])
37-
return bleach.clean(html, tags=allowed)
37+
return bleach.clean(html, tags=allowed, strip=True)
3838

3939
# ----------------------------------------------------------------------
4040
# Html fragment cleaning
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright The IETF Trust 2017-2020, All Rights Reserved
22
# -*- coding: utf-8 -*-
33

4+
import re
45

56
from django.template.library import Library
67
from django.template.defaultfilters import stringfilter
@@ -9,9 +10,9 @@
910

1011
register = Library()
1112

13+
1214
@register.filter(is_safe=True)
1315
@stringfilter
1416
def removetags(value, tags):
15-
"""Removes a space separated list of [X]HTML tags from the output."""
16-
return remove_tags(value, tags)
17-
17+
"""Removes a comma-separated list of [X]HTML tags from the output."""
18+
return remove_tags(value, re.split(r"\s*,\s*", tags))

0 commit comments

Comments
 (0)