Skip to content

Instantly share code, notes, and snippets.

@DamianMullins
Created August 13, 2012 19:47
Show Gist options
  • Save DamianMullins/3343580 to your computer and use it in GitHub Desktop.
Save DamianMullins/3343580 to your computer and use it in GitHub Desktop.
Filter out script tags from a string
@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