summaryrefslogtreecommitdiffstats
path: root/core/html.py
blob: e63dda3444f04dfe223c7a5f8267e760b5888476 (plain)
1
2
3
4
5
6
7
8
9
10
11
import bleach
from django.utils.safestring import mark_safe


def sanitize_post(post_html: str) -> str:
    """
    Only allows a, br, p and span tags, and class attributes.
    """
    return mark_safe(
        bleach.clean(post_html, tags=["a", "br", "p", "span"], attributes=["class"])
    )