Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.5.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 1edef50 from master
  • Loading branch information...
commit f832f0d2c309ac31bbf3616c34495c48509b0fb3 1 parent 9074d2f
@timgraham timgraham authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 docs/ref/utils.txt
View
11 docs/ref/utils.txt
@@ -746,6 +746,17 @@ appropriate entities.
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)
Explicitly mark a string as requiring HTML escaping upon output. Has no
Please sign in to comment.
Something went wrong with that request. Please try again.