From 0c6729937448396d28907977becfc84e8c153733 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 10 Mar 2020 08:16:24 +0530 Subject: [PATCH] Check Book: Do not fail if non-UTF-8 stylesheets are present in the book. Fixes #1866701 [Private bug](https://bugs.launchpad.net/calibre/+bug/1866701) --- src/calibre/ebooks/oeb/polish/check/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/polish/check/main.py b/src/calibre/ebooks/oeb/polish/check/main.py index b9c43ff6f2..f4715f50dc 100644 --- a/src/calibre/ebooks/oeb/polish/check/main.py +++ b/src/calibre/ebooks/oeb/polish/check/main.py @@ -48,16 +48,18 @@ def run_checks(container): xml_items, html_items, raster_images, stylesheets = [], [], [], [] for name, mt in iteritems(container.mime_map): items = None + decode = False if mt in XML_TYPES: items = xml_items elif mt in OEB_DOCS: items = html_items elif mt in OEB_STYLES: + decode = True items = stylesheets elif is_raster_image(mt): items = raster_images if items is not None: - items.append((name, mt, container.open(name, 'rb').read())) + items.append((name, mt, container.raw_data(name, decode=decode))) errors.extend(run_checkers(check_html_size, html_items)) errors.extend(run_checkers(check_xml_parsing, xml_items)) errors.extend(run_checkers(check_xml_parsing, html_items))