diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/defaultfilters.py | 9 | ||||
| -rw-r--r-- | django/utils/html.py | 29 |
2 files changed, 1 insertions, 37 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index d2c77508fe..8319c66eee 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -13,7 +13,7 @@ from django.utils.dateformat import format, time_format from django.utils.encoding import force_text, iri_to_uri from django.utils.html import ( avoid_wrapping, conditional_escape, escape, escapejs, linebreaks, - remove_tags, strip_tags, urlize as _urlize, + strip_tags, urlize as _urlize, ) from django.utils.http import urlquote from django.utils.safestring import SafeData, mark_for_escaping, mark_safe @@ -502,13 +502,6 @@ def safeseq(value): @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) - - -@register.filter(is_safe=True) -@stringfilter def striptags(value): """Strips all [X]HTML tags.""" return strip_tags(value) diff --git a/django/utils/html.py b/django/utils/html.py index 9387e712dc..1d86441a28 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -3,10 +3,8 @@ from __future__ import unicode_literals import re -import warnings from django.utils import six -from django.utils.deprecation import RemovedInDjango110Warning from django.utils.encoding import force_str, force_text from django.utils.functional import allow_lazy from django.utils.http import RFC3986_GENDELIMS, RFC3986_SUBDELIMS @@ -184,39 +182,12 @@ def strip_tags(value): strip_tags = allow_lazy(strip_tags) -def remove_tags(html, tags): - """Returns the given HTML with given tags removed.""" - warnings.warn( - "django.utils.html.remove_tags() and the removetags template filter " - "are deprecated. Consider using the bleach library instead.", - RemovedInDjango110Warning, stacklevel=3 - ) - tags = [re.escape(tag) for tag in tags.split()] - tags_re = '(%s)' % '|'.join(tags) - starttag_re = re.compile(r'<%s(/?>|(\s+[^>]*>))' % tags_re, re.U) - endtag_re = re.compile('</%s>' % tags_re) - html = starttag_re.sub('', html) - html = endtag_re.sub('', html) - return html -remove_tags = allow_lazy(remove_tags, six.text_type) - - def strip_spaces_between_tags(value): """Returns the given HTML with spaces between tags removed.""" return re.sub(r'>\s+<', '><', force_text(value)) strip_spaces_between_tags = allow_lazy(strip_spaces_between_tags, six.text_type) -def strip_entities(value): - """Returns the given HTML with all entities (&something;) stripped.""" - warnings.warn( - "django.utils.html.strip_entities() is deprecated.", - RemovedInDjango110Warning, stacklevel=2 - ) - return re.sub(r'&(?:\w+|#\d+);', '', force_text(value)) -strip_entities = allow_lazy(strip_entities, six.text_type) - - def smart_urlquote(url): "Quotes a URL if it isn't already quoted." def unquote_quote(segment): |
