From 4ad90f991aad79f6e550c19d28e9c0debf918954 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 17 Mar 2011 19:14:00 -0600 Subject: [PATCH] Conversion pipeline: Handle the case where the ncx file is incorrectly given an HTML mimetype --- src/calibre/ebooks/oeb/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 17cbc9c947..2e6ba82cb9 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -850,6 +850,7 @@ class Manifest(object): return data def _parse_xhtml(self, data): + orig_data = data self.oeb.log.debug('Parsing', self.href, '...') # Convert to Unicode and normalize line endings data = self.oeb.decode(data) @@ -927,6 +928,8 @@ class Manifest(object): # Handle weird (non-HTML/fragment) files if barename(data.tag) != 'html': + if self.href.endswith('.ncx'): + return self._parse_xml(orig_data) self.oeb.log.warn('File %r does not appear to be (X)HTML'%self.href) nroot = etree.fromstring('') has_body = False