Skip to content

Commit 7feda94

Browse files
committed
add custom url fetcher to allowed bleach protocols
1 parent 4fc54f3 commit 7feda94

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

doku/utils/markdown/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
"sub", "sup",
2020
]
2121

22-
2322
BLEACH_ALLOWED_ATTRS: dict = {
2423
"*": ["class", "id", "style"],
2524
"img": ["src", "alt", "title", "width", "height"],
2625
"a": ["href", "alt", "title"],
2726
}
27+
28+
BLEACH_ALLOWED_PROTOCOLS = ["http", "https", "dokures"]
29+
2830
# fmt: on
2931

3032

@@ -37,7 +39,10 @@ def compile_content(content: str, css_class: Optional[str], use_markdown: bool)
3739
else:
3840
# Make sure we sanitize content before saving it as
3941
# ``compiled_content`` even if we do not use markdown.
40-
content = bleach.clean(content, BLEACH_ALLOWED_TAGS, BLEACH_ALLOWED_ATTRS)
42+
content = bleach.clean(content,
43+
tags=BLEACH_ALLOWED_TAGS,
44+
attributes=BLEACH_ALLOWED_ATTRS,
45+
protocols=BLEACH_ALLOWED_PROTOCOLS)
4146
if use_markdown:
4247
return markdown.markdown(
4348
content,

0 commit comments

Comments
 (0)