From 08ea63266ed9342e0f3acf381bfe731b96dbe035 Mon Sep 17 00:00:00 2001 From: George Waters Date: Tue, 2 Aug 2022 23:34:34 -0400 Subject: [PATCH] Check validation when checking image align When 'align_floating_images' is True, this will call 'cssutils.parseStyle' and automatically validate the css. This may not be desired, so we use 'disable_validation' to determine whether or not to validate the css. --- premailer/premailer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/premailer/premailer.py b/premailer/premailer.py index 66907ca..ffd8a83 100644 --- a/premailer/premailer.py +++ b/premailer/premailer.py @@ -516,7 +516,9 @@ def transform(self, html=None, pretty_print=True, **kwargs): # understanding floats, but they do understand the HTML align attrib. if self.align_floating_images: for item in page.xpath("//img[@style]"): - image_css = cssutils.parseStyle(item.attrib["style"]) + image_css = cssutils.parseStyle( + item.attrib["style"], validate=not self.disable_validation + ) if image_css.float == "right": item.attrib["align"] = "right" elif image_css.float == "left":