mirror of
https://github.com/django/django.git
synced 2025-10-25 14:46:09 +00:00
[1.6.x] Improved strip_tags and clarified documentation
The fact that strip_tags 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/
Backport of 6ca6c36f8 from master.
This commit is contained in:
@@ -2012,7 +2012,7 @@ If ``value`` is ``10``, the output will be ``1.000000E+01``.
|
||||
striptags
|
||||
^^^^^^^^^
|
||||
|
||||
Strips all [X]HTML tags.
|
||||
Makes all possible efforts to strip all [X]HTML tags.
|
||||
|
||||
For example::
|
||||
|
||||
@@ -2021,6 +2021,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
|
||||
|
||||
Reference in New Issue
Block a user