1
0
mirror of https://github.com/django/django.git synced 2025-10-27 07:36:08 +00:00

Fixed #22130 -- Deprecated fix_ampersands, removed utils.clean_html()

This commit is contained in:
Erik Romijn
2014-03-01 10:42:08 +01:00
parent 8c98f39624
commit 775975f15d
7 changed files with 64 additions and 24 deletions

View File

@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import re
import warnings
from django.utils.safestring import SafeData, mark_safe
from django.utils.encoding import force_text, force_str
@@ -174,6 +175,9 @@ strip_entities = allow_lazy(strip_entities, six.text_type)
def fix_ampersands(value):
"""Returns the given HTML with all unencoded ampersands encoded correctly."""
# As fix_ampersands is wrapped in allow_lazy, stacklevel 3 is more useful than 2.
warnings.warn("The fix_ampersands function is deprecated and will be removed in Django 1.8.",
DeprecationWarning, stacklevel=3)
return unencoded_ampersands_re.sub('&', force_text(value))
fix_ampersands = allow_lazy(fix_ampersands, six.text_type)
@@ -290,6 +294,9 @@ def clean_html(text):
* Remove stuff like "<p>&nbsp;&nbsp;</p>", but only if it's at the
bottom of the text.
"""
# As clean_html is wrapped in allow_lazy, stacklevel 3 is more useful than 2.
warnings.warn("The clean_html function is deprecated and will be removed in Django 1.8.",
DeprecationWarning, stacklevel=3)
text = normalize_newlines(text)
text = re.sub(r'<(/?)\s*b\s*>', '<\\1strong>', text)
text = re.sub(r'<(/?)\s*i\s*>', '<\\1em>', text)