mirror of
https://github.com/django/django.git
synced 2025-09-26 20:19:16 +00:00
[1.6.x] Fixed #21316 -- Documented that modifying safe strings makes them unsafe.
Thanks dev@simon.net.nz for the suggestion and vijay_shanker for the patch.
Backport of 1edef50880
from master
This commit is contained in:
parent
aa645d20df
commit
da0c7723fa
1 changed files with 11 additions and 0 deletions
|
@ -790,6 +790,17 @@ appropriate entities.
|
||||||
|
|
||||||
Can be called multiple times on a single string.
|
Can be called multiple times on a single string.
|
||||||
|
|
||||||
|
String marked safe will become unsafe again if modified. For example::
|
||||||
|
|
||||||
|
>>> mystr = '<b>Hello World</b> '
|
||||||
|
>>> mystr = mark_safe(mystr)
|
||||||
|
>>> type(mystr)
|
||||||
|
<class 'django.utils.safestring.SafeBytes'>
|
||||||
|
|
||||||
|
>>> mystr = mystr.strip() # removing whitespace
|
||||||
|
>>> type(mystr)
|
||||||
|
<type 'str'>
|
||||||
|
|
||||||
.. function:: mark_for_escaping(s)
|
.. function:: mark_for_escaping(s)
|
||||||
|
|
||||||
Explicitly mark a string as requiring HTML escaping upon output. Has no
|
Explicitly mark a string as requiring HTML escaping upon output. Has no
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue