瀏覽代碼

Fixed #21316 -- Documented that modifying safe strings makes them unsafe.

Thanks dev@simon.net.nz for the suggestion and vijay_shanker for the patch.
Tim Graham 11 年之前
父節點
當前提交
1edef50880
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      docs/ref/utils.txt

+ 11 - 0
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