Skip to content

Instantly share code, notes, and snippets.

@psychok7
Last active December 18, 2015 02:59
Show Gist options
  • Save psychok7/5715301 to your computer and use it in GitHub Desktop.
Save psychok7/5715301 to your computer and use it in GitHub Desktop.
Django StripHtml Mixin with regular expressions to help avoid XSS
import re
class StripHtmlMixin(object):
#based on http://stackoverflow.com/a/3398894/977622
def strip_html(self, data):
p = re.compile(r'<.*?>')
return p.sub('', data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment