Created
June 4, 2010 07:35
-
-
Save qoelet/425105 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def escape(html): | |
""" | |
Returns the given HTML with ampersands, quotes and angle brackets encoded. | |
""" | |
return mark_safe(force_unicode(html).replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''')) | |
escape = allow_lazy(escape, unicode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment