Created
August 13, 2012 19:47
-
-
Save DamianMullins/3343580 to your computer and use it in GitHub Desktop.
Filter out script tags from a string
This file contains 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
@register.filter | |
@stringfilter | |
def stripjs(value): | |
stripped = re.sub(r'<script(?:\s[^>]*)?(>(?:.(?!/script>))*</script>|/>)', \ | |
'', force_unicode(value), flags=re.S) | |
return mark_safe(stripped) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment