mirror of https://github.com/django/django.git
Fixed #6071 -- Fixed another infinite recursion problem in SafeString and
SafeUnicode. Thanks, Trey Long. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6845 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
51dc4ecf94
commit
2e62b84acc
1
AUTHORS
1
AUTHORS
|
@ -207,6 +207,7 @@ answer newbie questions, and generally made Django that much better:
|
|||
Waylan Limberg <waylan@gmail.com>
|
||||
limodou
|
||||
Philip Lindborg <philip.lindborg@gmail.com>
|
||||
Trey Long <trey@ktrl.com>
|
||||
msaelices <msaelices@gmail.com>
|
||||
Matt McClanahan <http://mmcc.cx/>
|
||||
Martin Maney <http://www.chipy.org/Martin_Maney>
|
||||
|
|
|
@ -34,12 +34,12 @@ class SafeString(str, SafeData):
|
|||
Concatenating a safe string with another safe string or safe unicode
|
||||
object is safe. Otherwise, the result is no longer safe.
|
||||
"""
|
||||
t = super(SafeString, self).__add__(rhs)
|
||||
if isinstance(rhs, SafeUnicode):
|
||||
return SafeUnicode(self + rhs)
|
||||
return SafeUnicode(t)
|
||||
elif isinstance(rhs, SafeString):
|
||||
return SafeString(self + rhs)
|
||||
else:
|
||||
return super(SafeString, self).__add__(rhs)
|
||||
return SafeString(t)
|
||||
return t
|
||||
|
||||
def _proxy_method(self, *args, **kwargs):
|
||||
"""
|
||||
|
@ -66,10 +66,10 @@ class SafeUnicode(unicode, SafeData):
|
|||
Concatenating a safe unicode object with another safe string or safe
|
||||
unicode object is safe. Otherwise, the result is no longer safe.
|
||||
"""
|
||||
t = super(SafeUnicode, self).__add__(rhs)
|
||||
if isinstance(rhs, SafeData):
|
||||
return SafeUnicode(self + rhs)
|
||||
else:
|
||||
return super(SafeUnicode, self).__add__(rhs)
|
||||
return SafeUnicode(t)
|
||||
return t
|
||||
|
||||
def _proxy_method(self, *args, **kwargs):
|
||||
"""
|
||||
|
|
|
@ -43,7 +43,7 @@ u'django'
|
|||
Translating a string requiring no auto-escaping shouldn't change the "safe"
|
||||
status.
|
||||
|
||||
>>> from django.utils.safestring import mark_safe
|
||||
>>> from django.utils.safestring import mark_safe, SafeString
|
||||
>>> s = mark_safe('Password')
|
||||
>>> type(s)
|
||||
<class 'django.utils.safestring.SafeString'>
|
||||
|
@ -51,6 +51,19 @@ status.
|
|||
>>> type(ugettext(s))
|
||||
<class 'django.utils.safestring.SafeUnicode'>
|
||||
>>> deactivate()
|
||||
|
||||
>>> SafeString('a') + s
|
||||
'aPassword'
|
||||
>>> s + SafeString('a')
|
||||
'Passworda'
|
||||
>>> s + mark_safe('a')
|
||||
'Passworda'
|
||||
>>> mark_safe('a') + s
|
||||
'aPassword'
|
||||
>>> mark_safe('a') + mark_safe('s')
|
||||
'as'
|
||||
>>> print s
|
||||
Password
|
||||
"""
|
||||
|
||||
__test__ = {
|
||||
|
|
Loading…
Reference in New Issue