From 874367cef09c6c134354ad32f92204b3b66f2b81 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 19 Oct 2013 09:19:08 +0530 Subject: [PATCH] ODT Input: Handle malformed ODT files with no mimetype declaration --- src/odf/opendocument.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/odf/opendocument.py b/src/odf/opendocument.py index 69ada218aa..0b59b271a4 100644 --- a/src/odf/opendocument.py +++ b/src/odf/opendocument.py @@ -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