From fa6cb814ceffb018c97e7ae6c9af591772f45782 Mon Sep 17 00:00:00 2001 From: zPlus Date: Sat, 17 Jun 2023 06:12:08 +0200 Subject: [PATCH] Update bleach dependency. Change broken code from updated python3 "bleach" dependency. --- freepost/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/freepost/__init__.py b/freepost/__init__.py index 3431014f..a0bd7a59 100644 --- a/freepost/__init__.py +++ b/freepost/__init__.py @@ -37,8 +37,8 @@ template = functools.partial ( # TODO this should be renamed. It's only a way to pretty print dates 'title': lambda date: dateutil.parser.parse(date).strftime('%b %-d, %Y - %H:%M%z%Z'), # Convert markdown to plain text - 'md2txt': lambda text: bleach.clean (markdown.markdown (text), - tags=[], attributes={}, styles=[], strip=True), + 'md2txt': lambda text: bleach.clean (markdown.markdown(text), + tags=[], attributes={}, strip=True), # Convert markdown to html 'md2html': lambda text: bleach.clean (bleach.linkify (markdown.markdown ( text, @@ -66,7 +66,8 @@ template = functools.partial ( # "bleach" library is used to sanitize the HTML output of jinja2's "md2html" # filter. The library has only a very restrictive list of white-listed # tags, so we add some more here. -bleach.sanitizer.ALLOWED_TAGS += [ 'br', 'img', 'p', 'pre', 'h1', 'h2', 'h3', 'hr' ] +# The list() casting is required because it's of type "frozenlist" +bleach.sanitizer.ALLOWED_TAGS = list(bleach.sanitizer.ALLOWED_TAGS) + [ 'br', 'img', 'p', 'pre', 'h1', 'h2', 'h3', 'hr' ] bleach.sanitizer.ALLOWED_ATTRIBUTES.update ({ 'img': [ 'src' ] })