Viewer: Fix non-ASCII content in stylesheets not being interpreted correctly. Fixes #1848858 [Issue with viewer: '::before'](https://bugs.launchpad.net/calibre/+bug/1848858)

This commit is contained in:
Kovid Goyal 2019-10-20 16:52:00 +05:30
parent f10f23d4f6
commit c0fa79d58b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -502,6 +502,11 @@ class Container(ContainerBase):
def serialize_item(self, name): def serialize_item(self, name):
mt = (self.mime_map[name] or '').lower() 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: if mt not in OEB_DOCS:
return ContainerBase.serialize_item(self, name) return ContainerBase.serialize_item(self, name)
root = self.parsed(name) root = self.parsed(name)