mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
1cf5cbd00f
commit
8c4650977c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user