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>
|
Waylan Limberg <waylan@gmail.com>
|
||||||
limodou
|
limodou
|
||||||
Philip Lindborg <philip.lindborg@gmail.com>
|
Philip Lindborg <philip.lindborg@gmail.com>
|
||||||
|
Trey Long <trey@ktrl.com>
|
||||||
msaelices <msaelices@gmail.com>
|
msaelices <msaelices@gmail.com>
|
||||||
Matt McClanahan <http://mmcc.cx/>
|
Matt McClanahan <http://mmcc.cx/>
|
||||||
Martin Maney <http://www.chipy.org/Martin_Maney>
|
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
|
Concatenating a safe string with another safe string or safe unicode
|
||||||
object is safe. Otherwise, the result is no longer safe.
|
object is safe. Otherwise, the result is no longer safe.
|
||||||
"""
|
"""
|
||||||
|
t = super(SafeString, self).__add__(rhs)
|
||||||
if isinstance(rhs, SafeUnicode):
|
if isinstance(rhs, SafeUnicode):
|
||||||
return SafeUnicode(self + rhs)
|
return SafeUnicode(t)
|
||||||
elif isinstance(rhs, SafeString):
|
elif isinstance(rhs, SafeString):
|
||||||
return SafeString(self + rhs)
|
return SafeString(t)
|
||||||
else:
|
return t
|
||||||
return super(SafeString, self).__add__(rhs)
|
|
||||||
|
|
||||||
def _proxy_method(self, *args, **kwargs):
|
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
|
Concatenating a safe unicode object with another safe string or safe
|
||||||
unicode object is safe. Otherwise, the result is no longer safe.
|
unicode object is safe. Otherwise, the result is no longer safe.
|
||||||
"""
|
"""
|
||||||
|
t = super(SafeUnicode, self).__add__(rhs)
|
||||||
if isinstance(rhs, SafeData):
|
if isinstance(rhs, SafeData):
|
||||||
return SafeUnicode(self + rhs)
|
return SafeUnicode(t)
|
||||||
else:
|
return t
|
||||||
return super(SafeUnicode, self).__add__(rhs)
|
|
||||||
|
|
||||||
def _proxy_method(self, *args, **kwargs):
|
def _proxy_method(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -43,7 +43,7 @@ u'django'
|
||||||
Translating a string requiring no auto-escaping shouldn't change the "safe"
|
Translating a string requiring no auto-escaping shouldn't change the "safe"
|
||||||
status.
|
status.
|
||||||
|
|
||||||
>>> from django.utils.safestring import mark_safe
|
>>> from django.utils.safestring import mark_safe, SafeString
|
||||||
>>> s = mark_safe('Password')
|
>>> s = mark_safe('Password')
|
||||||
>>> type(s)
|
>>> type(s)
|
||||||
<class 'django.utils.safestring.SafeString'>
|
<class 'django.utils.safestring.SafeString'>
|
||||||
|
@ -51,6 +51,19 @@ status.
|
||||||
>>> type(ugettext(s))
|
>>> type(ugettext(s))
|
||||||
<class 'django.utils.safestring.SafeUnicode'>
|
<class 'django.utils.safestring.SafeUnicode'>
|
||||||
>>> deactivate()
|
>>> 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__ = {
|
__test__ = {
|
||||||
|
|
Loading…
Reference in New Issue