parent
dde5ed4650
commit
0038151bf9
|
@ -34,7 +34,7 @@ def unescape(text):
|
||||||
def remove_tags(html, tags):
|
def remove_tags(html, tags):
|
||||||
"""Returns the given HTML sanitized, and with the given tags removed."""
|
"""Returns the given HTML sanitized, and with the given tags removed."""
|
||||||
allowed = set(acceptable_tags) - set([ t.lower() for t in tags ])
|
allowed = set(acceptable_tags) - set([ t.lower() for t in tags ])
|
||||||
return bleach.clean(html, tags=allowed)
|
return bleach.clean(html, tags=allowed, strip=True)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Html fragment cleaning
|
# Html fragment cleaning
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Copyright The IETF Trust 2017-2020, All Rights Reserved
|
# Copyright The IETF Trust 2017-2020, All Rights Reserved
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from django.template.library import Library
|
from django.template.library import Library
|
||||||
from django.template.defaultfilters import stringfilter
|
from django.template.defaultfilters import stringfilter
|
||||||
|
@ -9,9 +10,9 @@ from ietf.utils.html import remove_tags
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
|
|
||||||
|
|
||||||
@register.filter(is_safe=True)
|
@register.filter(is_safe=True)
|
||||||
@stringfilter
|
@stringfilter
|
||||||
def removetags(value, tags):
|
def removetags(value, tags):
|
||||||
"""Removes a space separated list of [X]HTML tags from the output."""
|
"""Removes a comma-separated list of [X]HTML tags from the output."""
|
||||||
return remove_tags(value, tags)
|
return remove_tags(value, re.split(r"\s*,\s*", tags))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue