Санитайзеры
Markupsafe
from markupsafe import Markup
Markup.escape('<a href=x>t</a>')from markupsafe import Markup
Markup('<a href=x>t</a>')bleach
import bleach
ALLOWED_TAGS = [
'br', 'h1'
]
ALLOWED_ATTRS = {
'*': ['class'],
'a': ['href'],
'img': ['src'],
'div': ['id', 'some']
}
cleaned = bleach.clean(html_text, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRS)Last updated