Skip to main content

Bringing sanitiy to world of messed-up data

Project description

# Sanitize

[![Build Status](]( [![Coverage Status](]( [![Downloads](]( [![Version](]( [![Egg?](]( [![Wheel?](]( [![Format](]( [![License](](

sanitize is a Python module for making sure various things (e.g. HTML) are safe to use. It was originally written by Mark Pilgrim and is distributed under the BSD license.


` >>> from sanitize import HTML >>> HTML('<b>hello') '<b>hello</b>' >>> HTML('<img>') '<img />' >>> HTML(("<b><b><b>hello") ... ) '<b><b><b>hello</b></b></b>' >>> HTML('<img src="foo"/') '' >>> HTML('<input type="checkbox" checked>') '<input type="checkbox" checked="checked" />' >>> # dangerous tags (a small sample) ... >>> HTML('safe<applet code="foo.class" codebase=""></applet> <b>description</b>') 'safe <b>description</b>' >>> HTML('safe<frameset rows="*"><frame src=""></frameset> <b>description</b>') 'safe <b>description</b>' >>> # bad protocols (a small sample) >>> HTML('<a href="java' + chr(1) + 'script:foo">bar</a>') '<a href="#foo">bar</a>' >>> HTML('<a href="vbscript:foo">bar</a>') '<a href="#foo">bar</a>' >>> ` To see more usage examples see tests/


python-sanitize is available on pypi

So easily install it by pip:

` pip install sanitize `

Or by easy_install:

` $ easy_install sanitize `

Another way is by cloning python-sanitize’s git repository

` $ git clone git:// `

Then install it by running

` $ python install `


To run unit tests:

` $ python test `


Sanitize is distributed under BSD license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sanitize, version 2014.10.7
Filename, size File type Python version Upload date Hashes
Filename, size sanitize-2014.10.7.tar.gz (11.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page