MOBI metadata reader: Handle invalid PRC files with spurious image_offset headers

This commit is contained in:
Kovid Goyal 2010-12-14 18:57:04 -07:00
parent a9ffac7885
commit 491d1a8954

View File

@ -861,7 +861,10 @@ def get_metadata(stream):
cover_index = mh.first_image_index + mh.exth.cover_offset cover_index = mh.first_image_index + mh.exth.cover_offset
data = mh.section_data(int(cover_index)) data = mh.section_data(int(cover_index))
else: else:
try:
data = mh.section_data(mh.first_image_index) data = mh.section_data(mh.first_image_index)
except:
data = ''
buf = cStringIO.StringIO(data) buf = cStringIO.StringIO(data)
try: try:
im = PILImage.open(buf) im = PILImage.open(buf)