Ticket #4230 (closed defect: fixed)

Opened 9 months ago

Last modified 9 months ago

Can't view/convert certain Mobipocket files

Reported by: pdurrant Owned by: kovidgoyal
Priority: major Milestone:
Component: MOBI Input Version: trunk
Keywords: Cc:

Description

Certain Mobipocket files give an error on viewing or converting: "string index out of range". Here's a sample traceback:

ERROR: Could not open ebook: string index out of range

Traceback (most recent call last):

File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/gui2/viewer/main.py", line 59, in run

Thread.run(self)

File "threading.pyo", line 477, in run File "calibre/ebooks/oeb/iterator.pyo", line 175, in enter File "calibre/customize/conversion.pyo", line 208, in call File "calibre/ebooks/mobi/input.pyo", line 22, in convert File "calibre/ebooks/mobi/reader.pyo", line 295, in extract_content File "calibre/ebooks/mobi/reader.pyo", line 679, in extract_text File "calibre/ebooks/mobi/reader.pyo", line 674, in text_section File "calibre/ebooks/mobi/reader.pyo", line 666, in sizeof_trailing_entries File "calibre/ebooks/mobi/reader.pyo", line 654, in sizeof_trailing_entry

Index Error?: string index out of range

the problem comes from the undocumented nature of the Mobipocket files. The mobile read wiki suggested that the Extra Data Flags were present in all MOBI eaders with size >=0xE4. This turns out not to be true. They are not present in some, I'd guess all, files with MOBI header length 0xE4. In many mobipocket files with MOBI header length 0xE4, the last two bytes are zero, so this error causes no problems. In some, they are non-zero, which leads to this string index out of range error.

A simple fix might be to only extract the Extra Data Flags when the mobi header length is 0xE8 or more.

A sample file is the de-drmed (with Mobidedrm 0.07) ebook  http://www.fictionwise.com/ebooks/b23741/Fortress-of-Dragons-/C-J-Cherryh/?

The sample problem was found to affect Mobidedrm 0.06.

Change History

comment:1 Changed 9 months ago by kovidgoyal

can you attach or email (kovid at kovidgoyal. net) the dedrmed file to me.

comment:2 Changed 9 months ago by kovidgoyal

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in branch trunk. The fix will be in the next release.

Note: See TracTickets for help on using tickets.