Popular Python recipes tagged "meta:requires=formatter"http://code.activestate.com/recipes/langs/python/tags/meta:requires=formatter/2006-08-05T10:45:10-07:00ActiveState Code RecipesCross-site scripting (XSS) defense (Python)
2006-08-05T10:45:10-07:00Josh Goldfoothttp://code.activestate.com/recipes/users/2960005/http://code.activestate.com/recipes/496942-cross-site-scripting-xss-defense/
<p style="color: grey">
Python
recipe 496942
by <a href="/recipes/users/2960005/">Josh Goldfoot</a>
(<a href="/recipes/tags/web/">web</a>).
</p>
<p>This cleanses user input of potentially dangerous HTML or scripting code that can be used to launch "cross-site scripting" ("XSS") attacks, or run other harmful or annoying code. You want to run this on any user-entered text that will be saved and retransmitted to other users of your web site. This uses only standard Python libraries.</p>
htmltotext converter w/ tty support for bold/underline (Python)
2004-01-30T16:44:42-08:00Brent Burleyhttp://code.activestate.com/recipes/users/98036/http://code.activestate.com/recipes/52297-htmltotext-converter-w-tty-support-for-boldunderli/
<p style="color: grey">
Python
recipe 52297
by <a href="/recipes/users/98036/">Brent Burley</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 2.
</p>
<p>This is a complete program that reads an html doc and converts it to
plain ASCII text. In the spirit of minimalism, this operates as a
standard unix filter.
E.g. htmltotext < foo.html > foo.txt</p>
<p>If the output is going to a terminal, then bold and underline are
displayed on the terminal. Italics in HTML are mapped to underlining
on the tty. Underlining in HTML is ignored (mostly due to laziness).</p>