ODT Input: Handle malformed ODT files with no mimetype declaration

This commit is contained in:
Kovid Goyal 2013-10-19 09:19:08 +05:30
parent 66263fdef1
commit 874367cef0

View File

@ -607,7 +607,10 @@ def load(odffile):
Returns a reference to the structure
"""
z = zipfile.ZipFile(odffile)
mimetype = z.read('mimetype')
try:
mimetype = z.read('mimetype')
except KeyError: # Added by Kovid to handle malformed odt files
mimetype = 'application/vnd.oasis.opendocument.text'
doc = OpenDocument(mimetype, add_generator=False)
# Look in the manifest file to see if which of the four files there are