Conversion pipeline: Handle the case where the ncx file is incorrectly given an HTML mimetype

This commit is contained in:
Kovid Goyal 2011-03-17 19:14:00 -06:00
parent 3dc878e911
commit 4ad90f991a

View File

@ -850,6 +850,7 @@ class Manifest(object):
return data return data
def _parse_xhtml(self, data): def _parse_xhtml(self, data):
orig_data = data
self.oeb.log.debug('Parsing', self.href, '...') self.oeb.log.debug('Parsing', self.href, '...')
# Convert to Unicode and normalize line endings # Convert to Unicode and normalize line endings
data = self.oeb.decode(data) data = self.oeb.decode(data)
@ -927,6 +928,8 @@ class Manifest(object):
# Handle weird (non-HTML/fragment) files # Handle weird (non-HTML/fragment) files
if barename(data.tag) != 'html': 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) self.oeb.log.warn('File %r does not appear to be (X)HTML'%self.href)
nroot = etree.fromstring('<html></html>') nroot = etree.fromstring('<html></html>')
has_body = False has_body = False