summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2013-04-20 13:38:14 +0200
committerClaude Paroz <claude@2xlibre.net>2013-05-25 16:06:44 +0200
commit2ee447fb5f8974b432d3dd421af9a242215aea44 (patch)
tree2bc2e50185bf04376f0a5685e2d66fb66786db82 /django/utils
parentbe0bab1bb8da80402248cd1fa22fd4cc09b34fe7 (diff)
Fixed #20296 -- Allowed SafeData and EscapeData to be lazy
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/safestring.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/django/utils/safestring.py b/django/utils/safestring.py
index 07e0bf4cea..3774012d32 100644
--- a/django/utils/safestring.py
+++ b/django/utils/safestring.py
@@ -4,7 +4,7 @@ without further escaping in HTML. Marking something as a "safe string" means
that the producer of the string has already turned characters that should not
be interpreted by the HTML engine (e.g. '<') into the appropriate entities.
"""
-from django.utils.functional import curry, Promise
+from django.utils.functional import curry, Promise, allow_lazy
from django.utils import six
class EscapeData(object):
@@ -14,13 +14,13 @@ class EscapeBytes(bytes, EscapeData):
"""
A byte string that should be HTML-escaped when output.
"""
- pass
+ __new__ = allow_lazy(bytes.__new__, bytes)
class EscapeText(six.text_type, EscapeData):
"""
A unicode string object that should be HTML-escaped when output.
"""
- pass
+ __new__ = allow_lazy(six.text_type.__new__, six.text_type)
if six.PY3:
EscapeString = EscapeText
@@ -37,6 +37,8 @@ class SafeBytes(bytes, SafeData):
A bytes subclass that has been specifically marked as "safe" (requires no
further escaping) for HTML output purposes.
"""
+ __new__ = allow_lazy(bytes.__new__, bytes)
+
def __add__(self, rhs):
"""
Concatenating a safe byte string with another safe byte string or safe
@@ -69,6 +71,8 @@ class SafeText(six.text_type, SafeData):
A unicode (Python 2) / str (Python 3) subclass that has been specifically
marked as "safe" for HTML output purposes.
"""
+ __new__ = allow_lazy(six.text_type.__new__, six.text_type)
+
def __add__(self, rhs):
"""
Concatenating a safe unicode string with another safe byte string or