This repository has been archived on 2023-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
takahe/core/html.py

12 lines
295 B
Python
Raw Normal View History

2022-11-12 06:02:43 +01:00
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"])
)