diff options
| author | Claude Paroz <claude@2xlibre.net> | 2014-03-22 11:14:15 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2014-03-22 11:19:58 +0100 |
| commit | f108b1f7d79526fb2fc0a6ff212744cffb399d15 (patch) | |
| tree | a58d219a16bc7134294e61c2a38f3a1bcfc99d40 | |
| parent | b8713ee69a7a171a01cf94c56d3b83bc09e41506 (diff) | |
[1.4.x] Clarified striptags documentation
The fact that striptags cannot guarantee to really strip all
non-safe HTML content was not clear enough. Also see:
https://www.djangoproject.com/weblog/2014/mar/22/strip-tags-advisory/
Partial backport (doc-only) of 6ca6c36f82 from master.
| -rw-r--r-- | docs/ref/templates/builtins.txt | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index e911bb167b..e2734c9747 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -1988,7 +1988,7 @@ If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel is a slug"``. striptags ^^^^^^^^^ -Strips all [X]HTML tags. +Makes all possible efforts to strip all [X]HTML tags. For example:: @@ -1997,6 +1997,16 @@ For example:: If ``value`` is ``"<b>Joel</b> <button>is</button> a <span>slug</span>"``, the output will be ``"Joel is a slug"``. +.. admonition:: No safety guarantee + + Note that ``striptags`` doesn't give any guarantee about its output being + entirely HTML safe, particularly with non valid HTML input. So **NEVER** + apply the ``safe`` filter to a ``striptags`` output. + If you are looking for something more robust, you can use the ``bleach`` + Python library, notably its `clean`_ method. + +.. _clean: http://bleach.readthedocs.org/en/latest/clean.html + .. templatefilter:: time time |
