Uses library for html cleanup
This commit is contained in:
parent
58b23a74da
commit
7f78140015
6 changed files with 44 additions and 102 deletions
25
bookwyrm/utils/sanitizer.py
Normal file
25
bookwyrm/utils/sanitizer.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
"""Clean user-provided text"""
|
||||
import bleach
|
||||
|
||||
|
||||
def clean(input_text):
|
||||
"""Run through "bleach" """
|
||||
return bleach.clean(
|
||||
input_text,
|
||||
tags=[
|
||||
"p",
|
||||
"blockquote",
|
||||
"br",
|
||||
"b",
|
||||
"i",
|
||||
"strong",
|
||||
"em",
|
||||
"pre",
|
||||
"a",
|
||||
"span",
|
||||
"ul",
|
||||
"ol",
|
||||
"li",
|
||||
],
|
||||
attributes=["href", "rel", "src", "alt"],
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue