Bleach is an HTML sanitation library that escapes or strips markup and
attributes based on a white list. Bleach can also linkify text safely, applying
filters that Django's
urlize filter cannot, and optionally setting
attributes, even on links already in the text.
Bleach is intended for sanitizing text from untrusted sources.
Because it relies on html5lib, Bleach is as good as modern browsers at dealing
with weird, quirky HTML fragments. Bleach's methods will fix
unbalanced or mis-nested tags.
Documentation is at http://bleach.readthedocs.org/ .