summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-10-30 08:11:31 -0400
committerTim Graham <timograham@gmail.com>2013-10-30 08:11:31 -0400
commit1edef50880f740e00fa1cd501c2ac56ec6fd10e4 (patch)
tree6202040858e11d52534689f97ad452ac71c6c527 /docs
parentb47a052eb50567813d629e332bb0428d73c8892e (diff)
Fixed #21316 -- Documented that modifying safe strings makes them unsafe.
Thanks dev@simon.net.nz for the suggestion and vijay_shanker for the patch.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/utils.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index e03a775d60..a1e74b0810 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -764,6 +764,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