From c0fa79d58bc43cb3dbd32f87c96fcd21791784cf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 20 Oct 2019 16:52:00 +0530 Subject: [PATCH] Viewer: Fix non-ASCII content in stylesheets not being interpreted correctly. Fixes #1848858 [Issue with viewer: '::before'](https://bugs.launchpad.net/calibre/+bug/1848858) --- src/calibre/srv/render_book.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calibre/srv/render_book.py b/src/calibre/srv/render_book.py index da49067790..d44d85b9ff 100644 --- a/src/calibre/srv/render_book.py +++ b/src/calibre/srv/render_book.py @@ -502,6 +502,11 @@ class Container(ContainerBase): def serialize_item(self, name): mt = (self.mime_map[name] or '').lower() + if mt in OEB_STYLES: + ans = ContainerBase.serialize_item(self, name).lstrip() + if not ans.startswith(b'@charset'): + ans = b'@charset "UTF-8";\n' + ans + return ans if mt not in OEB_DOCS: return ContainerBase.serialize_item(self, name) root = self.parsed(name)