AZW3 Input: Ignore incorrect text encoding (incorrectly encoded bytes are now replaced by placeholders) instead of erroring out. Fixes #1465769 [convert file failed: azw3 -> mobi](https://bugs.launchpad.net/calibre/+bug/1465769)

This commit is contained in:
Kovid Goyal 2015-06-17 03:22:29 +05:30
parent 1cf5cbd00f
commit 8c4650977c

View File

@ -49,7 +49,11 @@ def update_internal_links(mobi8_reader, log):
tag = posfid_index_pattern.sub(b'"' + replacement + b'"', tag, 1)
srcpieces[j] = tag
raw = b''.join(srcpieces)
parts.append(raw.decode(mr.header.codec))
try:
parts.append(raw.decode(mr.header.codec))
except UnicodeDecodeError:
log.warn('Failed to decode text in KF8 part, replacing bad bytes')
parts.append(raw.decode(mr.header.codec, 'replace'))
# All parts are now unicode and have no internal links
return parts