~sircmpwn/core.sr.ht

066835900f6439d2d215d05a1ed745c4c32f7848 — delthas 3 months ago 16d8c70 0.68.21
Fix bleach sanitizing imports

Bleach changed the way CSS is sanitized in 5.0.0 in a non
retro-compatible manner, removing previous imports and adding a new way
to sanitize CSS.

The ALLOWED_STYLES list was empty, so there is no attribute to copy from
it. We merely use a CSSSanitizer which is the new way to specify how CSS
must be sanitized.
1 files changed, 3 insertions(+), 2 deletions(-)

M srht/markdown.py
M srht/markdown.py => srht/markdown.py +3 -2
@@ 7,6 7,7 @@ from pygments.formatters import HtmlFormatter, ClassNotFound
from pygments.lexers import get_lexer_by_name
from urllib.parse import urlparse, urlunparse
import bleach
import bleach.css_sanitizer
import html
import mistletoe as m
from mistletoe.span_token import SpanToken, RawText


@@ 177,12 178,12 @@ _sanitizer = bleach.sanitizer.Cleaner(
        'matrix',
        'xmpp',
    ],
    styles=bleach.sanitizer.ALLOWED_STYLES + [
    css_sanitizer=bleach.css_sanitizer.CSSSanitizer(allowed_svg_properties=[], allowed_css_properties=[
        "margin", "padding",
        "text-align", "font-weight", "text-decoration"
    ]
    + [f"padding-{p}" for p in ["left", "right", "bottom", "top"]]
    + [f"margin-{p}"  for p in ["left", "right", "bottom", "top"]],
    + [f"margin-{p}"  for p in ["left", "right", "bottom", "top"]]),
    strip=True)

def sanitize(html):