Skip to content

Instantly share code, notes, and snippets.

View justinline's full-sized avatar

Justin Focus justinline

View GitHub Profile
@justinline
justinline / html_tags.py
Created November 28, 2017 20:02 — forked from epicserve/html_tags.py
Example of using bleach to strip out bad/evil code.
from django import template
from django.utils.safestring import mark_safe
import bleach
register = template.Library()
@register.filter
def strip_tags(text, valid_tags=['p', 'a', 'strong', 'em', 'ol', 'ul', 'li']):
if not isinstance(valid_tags, list):