summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-08-11 07:24:51 -0400
committerTim Graham <timograham@gmail.com>2014-08-15 08:20:02 -0400
commite122facbd89c5768528f5ba3b13552d43f989757 (patch)
tree84f990612dffbb119a8620e1dccae10f4f76c45f /django
parentdeed00c0d803d324a3dfdeba52458b6b009c1a90 (diff)
Fixed #23269 -- Deprecated django.utils.remove_tags() and removetags filter.
Also the unused, undocumented django.utils.html.strip_entities() function.
Diffstat (limited to 'django')
-rw-r--r--django/utils/html.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index d5fe2f4a6b..0ecd48957a 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -4,7 +4,9 @@ from __future__ import unicode_literals
import re
import sys
+import warnings
+from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, force_str
from django.utils.functional import allow_lazy
from django.utils.http import RFC3986_GENDELIMS, RFC3986_SUBDELIMS
@@ -177,6 +179,11 @@ 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.",
+ RemovedInDjango20Warning, 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)
@@ -195,6 +202,10 @@ 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.",
+ RemovedInDjango20Warning, stacklevel=2
+ )
return re.sub(r'&(?:\w+|#\d+);', '', force_text(value))
strip_entities = allow_lazy(strip_entities, six.text_type)