Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #21316 -- Documented that modifying safe strings makes them uns…

…afe.

Thanks dev@simon.net.nz for the suggestion and vijay_shanker for the patch.
  • Loading branch information...
commit 1edef50880f740e00fa1cd501c2ac56ec6fd10e4 1 parent b47a052
Tim Graham authored October 30, 2013

Showing 1 changed file with 11 additions and 0 deletions. Show diff stats Hide diff stats

  1. 11  docs/ref/utils.txt
11  docs/ref/utils.txt
@@ -764,6 +764,17 @@ appropriate entities.
764 764
 
765 765
     Can be called multiple times on a single string.
766 766
 
  767
+    String marked safe will become unsafe again if modified. For example::
  768
+
  769
+        >>> mystr = '<b>Hello World</b>   '
  770
+        >>> mystr = mark_safe(mystr)
  771
+        >>> type(mystr)
  772
+        <class 'django.utils.safestring.SafeBytes'>
  773
+
  774
+        >>> mystr = mystr.strip()  # removing whitespace
  775
+        >>> type(mystr)
  776
+        <type 'str'>
  777
+
767 778
 .. function:: mark_for_escaping(s)
768 779
 
769 780
     Explicitly mark a string as requiring HTML escaping upon output. Has no

0 notes on commit 1edef50

Please sign in to comment.
Something went wrong with that request. Please try again.