Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ietf/utils/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def unescape(text):
def remove_tags(html, tags):
"""Returns the given HTML sanitized, and with the given tags removed."""
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
Expand Down
7 changes: 4 additions & 3 deletions ietf/utils/templatetags/htmlfilters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright The IETF Trust 2017-2020, All Rights Reserved
# -*- coding: utf-8 -*-

import re

from django.template.library import Library
from django.template.defaultfilters import stringfilter
Expand All @@ -9,9 +10,9 @@

register = Library()


@register.filter(is_safe=True)
@stringfilter
def removetags(value, tags):
"""Removes a space separated list of [X]HTML tags from the output."""
return remove_tags(value, tags)

"""Removes a comma-separated list of [X]HTML tags from the output."""
return remove_tags(value, re.split(r"\s*,\s*", tags))