From dc636725fa26b08501807fbfb23a81f9ac197f93 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 8 Nov 2018 09:52:30 +0530 Subject: [PATCH] EPUB Input: Handle invalid EPUB files that have their NCX documents in the spine. Fixes #1796497 [AttributeError: 'NoneType' object has no attribute 'get'](https://bugs.launchpad.net/calibre/+bug/1796497) --- src/calibre/ebooks/oeb/reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/reader.py b/src/calibre/ebooks/oeb/reader.py index 736e110bb8..844f0c33d3 100644 --- a/src/calibre/ebooks/oeb/reader.py +++ b/src/calibre/ebooks/oeb/reader.py @@ -337,7 +337,7 @@ class OEBReader(object): self.logger.warn(u'Spine item %r not found' % idref) continue item = manifest.ids[idref] - if item.media_type.lower() in OEB_DOCS and hasattr(item.data, 'xpath'): + if item.media_type.lower() in OEB_DOCS and hasattr(item.data, 'xpath') and not getattr(item.data, 'tag', '').endswith('}ncx'): spine.add(item, elem.get('linear')) else: if hasattr(item.data, 'tag') and item.data.tag and item.data.tag.endswith('}html'):