2022-07-04 13:14:22 -07:00
|
|
|
"""Clean user-provided text"""
|
|
|
|
import bleach
|
|
|
|
|
|
|
|
|
2023-08-02 19:30:40 +02:00
|
|
|
def clean(input_text: str) -> str:
|
2022-07-04 13:14:22 -07:00
|
|
|
"""Run through "bleach" """
|
|
|
|
return bleach.clean(
|
|
|
|
input_text,
|
|
|
|
tags=[
|
|
|
|
"p",
|
|
|
|
"blockquote",
|
|
|
|
"br",
|
|
|
|
"b",
|
|
|
|
"i",
|
|
|
|
"strong",
|
|
|
|
"em",
|
|
|
|
"pre",
|
|
|
|
"a",
|
|
|
|
"span",
|
|
|
|
"ul",
|
|
|
|
"ol",
|
|
|
|
"li",
|
|
|
|
],
|
2023-02-18 00:18:32 +01:00
|
|
|
attributes=["href", "rel", "src", "alt", "data-mention"],
|
2022-07-04 13:45:28 -07:00
|
|
|
strip=True,
|
2022-07-04 13:14:22 -07:00
|
|
|
)
|