fix: Prepare for the bleach 6.0.0 upgrad.

Changelog: https://bleach.readthedocs.io/en/latest/changes.html#version-6-0-0-january-23rd-2023

The major change is that the tags and protocols attributes and related
constants are expected to be sets rather than lists.
This commit is contained in:
Feanil Patel
2023-01-31 10:59:21 -05:00
parent 2e4a20eded
commit 57f2ca1a21
5 changed files with 10 additions and 14 deletions

View File

@@ -191,8 +191,8 @@ def sanitize_html(html_code):
})
output = bleach.clean(
html_code,
protocols=bleach.ALLOWED_PROTOCOLS + ['data'],
tags=bleach.ALLOWED_TAGS + ['div', 'p', 'audio', 'pre', 'img', 'span'],
protocols=bleach.ALLOWED_PROTOCOLS | {'data'},
tags=bleach.ALLOWED_TAGS | {'div', 'p', 'audio', 'pre', 'img', 'span'},
css_sanitizer=CSSSanitizer(allowed_css_properties=["white-space"]),
attributes=attributes
)
@@ -216,12 +216,12 @@ def remove_markup(html):
"""
Return html with markup stripped and text HTML-escaped.
>>> bleach.clean("<b>Rock & Roll</b>", tags=[], strip=True)
>>> bleach.clean("<b>Rock & Roll</b>", tags=set(), strip=True)
'Rock &amp; Roll'
>>> bleach.clean("<b>Rock &amp; Roll</b>", tags=[], strip=True)
>>> bleach.clean("<b>Rock &amp; Roll</b>", tags=set(), strip=True)
'Rock &amp; Roll'
"""
return HTML(bleach.clean(html, tags=[], strip=True))
return HTML(bleach.clean(html, tags=set(), strip=True))
def get_course_id_from_capa_block(capa_block):