This commit is contained in:
Kovid Goyal 2012-03-18 13:27:00 +05:30
parent 9712175d74
commit dd20e427b5
2 changed files with 6 additions and 1 deletions

View File

@ -186,6 +186,8 @@ class BookHeader(object):
if len(raw) >= 0xF8:
self.ncxidx, = struct.unpack_from(b'>L', raw, 0xF4)
# Ancient PRC files from Baen can have random values for
# mobi_version, so be conservative
if self.mobi_version == 8 and len(raw) >= (0xF8 + 16):
self.dividx, self.skelidx, self.datpidx, self.othidx = \
struct.unpack_from(b'>4L', raw, 0xF8)

View File

@ -107,7 +107,10 @@ class MobiReader(object):
self.kf8_type = None
k8i = getattr(self.book_header.exth, 'kf8_header', None)
if self.book_header.mobi_version == 8:
# Ancient PRC files from Baen can have random values for
# mobi_version, so be conservative
if (self.book_header.mobi_version == 8 and hasattr(self.book_header,
'skelidx')):
self.kf8_type = 'standalone'
elif k8i is not None: # Check for joint mobi 6 and kf 8 file
try: