mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
MOBI Input: Fix regression that caused a mixup of images when the MOBI file header contains an incorrect first image index pointer. Fixes #911243 (Private bug)
This commit is contained in:
parent
05312e6389
commit
bb94a8dbe2
@ -1410,9 +1410,11 @@ class MOBIFile(object): # {{{
|
||||
self.mobi_header.extra_data_flags, decompress) for r in xrange(1,
|
||||
min(len(self.records), ntr+1))]
|
||||
self.image_records, self.binary_records = [], []
|
||||
image_index = 0
|
||||
for i in xrange(fntbr, len(self.records)):
|
||||
if i in self.indexing_record_nums or i in self.huffman_record_nums:
|
||||
continue
|
||||
image_index += 1
|
||||
r = self.records[i]
|
||||
fmt = None
|
||||
if i >= fii and r.raw[:4] not in (b'FLIS', b'FCIS', b'SRCS',
|
||||
@ -1422,7 +1424,7 @@ class MOBIFile(object): # {{{
|
||||
except:
|
||||
pass
|
||||
if fmt is not None:
|
||||
self.image_records.append(ImageRecord(len(self.image_records)+1, r, fmt))
|
||||
self.image_records.append(ImageRecord(image_index, r, fmt))
|
||||
else:
|
||||
self.binary_records.append(BinaryRecord(i, r))
|
||||
|
||||
|
@ -974,12 +974,13 @@ class MobiReader(object):
|
||||
continue
|
||||
processed_records.append(i)
|
||||
data = self.sections[i][0]
|
||||
image_index += 1
|
||||
if data[:4] in {b'FLIS', b'FCIS', b'SRCS', b'\xe9\x8e\r\n',
|
||||
b'RESC', b'BOUN', b'FDST', b'DATP', b'AUDI', b'VIDE'}:
|
||||
# A FLIS, FCIS, SRCS or EOF record, ignore
|
||||
# This record is a known non image type, not need to try to
|
||||
# load the image
|
||||
continue
|
||||
buf = cStringIO.StringIO(data)
|
||||
image_index += 1
|
||||
try:
|
||||
im = PILImage.open(buf)
|
||||
im = im.convert('RGB')
|
||||
|
Loading…
x
Reference in New Issue
Block a user