From 0ea77174224dbc3f1a20c134eb670cd3833ebb2e Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Fri, 7 Feb 2025 01:14:34 +0300 Subject: [PATCH] Add CSS sanitization for image dimensions in HTML sanitization --- post_parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/post_parser.py b/post_parser.py index 91185bb..a989e2f 100644 --- a/post_parser.py +++ b/post_parser.py @@ -226,7 +226,10 @@ class PostParser: html, tags=self.allowed_tags, attributes=self.allowed_attributes, - strip=True + strip=True, + css_sanitizer=bleach.css_sanitizer.CSSSanitizer( + allowed_css_properties=['max-width', 'max-height', 'width', 'height', 'object-fit'] + ) ) except Exception as e: logger.error(f"html_sanitization_error: {str(e)}")