mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 04:03:52 +02:00
KF8 Input: Do not error out if the file has a few invalidly encoded bytes. Fixes #997034 (Book opening after import stops with invalid continuation byte)
This commit is contained in:
parent
38747f1d3f
commit
d6c69c8579
2 changed files with 7 additions and 3 deletions
|
|
@ -111,7 +111,11 @@ def update_flow_links(mobi8_reader, resource_map, log):
|
|||
continue
|
||||
|
||||
if not isinstance(flow, unicode):
|
||||
flow = flow.decode(mr.header.codec)
|
||||
try:
|
||||
flow = flow.decode(mr.header.codec)
|
||||
except UnicodeDecodeError:
|
||||
log.error('Flow part has invalid %s encoded bytes'%mr.header.codec)
|
||||
flow = flow.decode(mr.header.codec, 'replace')
|
||||
|
||||
# links to raster image files from image tags
|
||||
# image_pattern
|
||||
|
|
|
|||
|
|
@ -207,9 +207,9 @@ def build_parts(self):
|
|||
fname = 'svgimg' + nstr + '.svg'
|
||||
else:
|
||||
# search for CDATA and if exists inline it
|
||||
if flowpart.find('[CDATA[') >= 0:
|
||||
if flowpart.find(b'[CDATA[') >= 0:
|
||||
typ = 'css'
|
||||
flowpart = '<style type="text/css">\n' + flowpart + '\n</style>\n'
|
||||
flowpart = b'<style type="text/css">\n' + flowpart + b'\n</style>\n'
|
||||
format = 'inline'
|
||||
dir = None
|
||||
fname = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue