Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 46 lines (32 sloc) 1.666 kb
efc4827 New version, new docs, simpler API.
James Socol authored
1 ======
65a9548 README
James Socol authored
2 Bleach
3 ======
4
efc4827 New version, new docs, simpler API.
James Socol authored
5 Bleach is an HTML sanitizing library that escapes or strips markup and
6 attributes based on a white list. Bleach can also linkify text safely, applying
7 filters that Django's ``urlize`` filter cannot, and optionally setting ``rel``
8 attributes, even on links already in the text.
65a9548 README
James Socol authored
9
8735837 Update version and docs.
James Socol authored
10 Bleach is intended for sanitizing text from *untrusted* sources. If you find
11 yourself jumping through hoops to allow your site administrators to do lots of
12 things, you're probably outside the use cases. Either trust those users, or
13 don't.
14
15 Because it relies on html5lib_, Bleach is as good as modern browsers at dealing
16 with weird, quirky HTML fragments. And *any* of Bleach's methods will fix
17 unbalanced or mis-nested tags.
18
1d0e907 Update docs, fix #71.
James Socol authored
19 The version on GitHub_ is the most up-to-date and contains the latest bug
20 fixes. You can find full documentation on `ReadTheDocs`_.
dcf900f Added a pointer to github to the readme.
James Socol authored
21
65a9548 README
James Socol authored
22
23 Basic Use
efc4827 New version, new docs, simpler API.
James Socol authored
24 =========
65a9548 README
James Socol authored
25
efc4827 New version, new docs, simpler API.
James Socol authored
26 The simplest way to use Bleach is::
65a9548 README
James Socol authored
27
efc4827 New version, new docs, simpler API.
James Socol authored
28 >>> import bleach
65a9548 README
James Socol authored
29
efc4827 New version, new docs, simpler API.
James Socol authored
30 >>> bleach.clean('an <script>evil()</script> example')
3657f7e Fix README unicode issue.
James Socol authored
31 u'an &lt;script&gt;evil()&lt;/script&gt; example'
65a9548 README
James Socol authored
32
efc4827 New version, new docs, simpler API.
James Socol authored
33 >>> bleach.linkify('an http://example.com url')
3657f7e Fix README unicode issue.
James Socol authored
34 u'an <a href="http://example.com" rel="nofollow">http://example.com</a> url
35
56d4690 Document character encoding behavior. Fix #41.
James Socol authored
36 *NB*: Bleach always returns a ``unicode`` object, whether you give it a
37 bytestring or a ``unicode`` object, but Bleach does not attempt to detect
38 incoming character encodings, and will assume UTF-8. If you are using a
39 different character encoding, you should convert from a bytestring to
40 ``unicode`` before passing the text to Bleach.
65a9548 README
James Socol authored
41
42
8735837 Update version and docs.
James Socol authored
43 .. _html5lib: http://code.google.com/p/html5lib/
1d0e907 Update docs, fix #71.
James Socol authored
44 .. _GitHub: http://github.com/jsocol/bleach
45 .. _ReadTheDocs: http://bleach.readthedocs.org/
Something went wrong with that request. Please try again.