From 67e691c2ff886caf4e98368d8702172d1f39e41d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Jan 2013 21:19:55 +0530 Subject: [PATCH] Conversion: Preserve ToC entries that point nowhere instead of causing them to point to a non-existant file --- src/calibre/ebooks/oeb/reader.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/calibre/ebooks/oeb/reader.py b/src/calibre/ebooks/oeb/reader.py index 0461491d2f..68db089073 100644 --- a/src/calibre/ebooks/oeb/reader.py +++ b/src/calibre/ebooks/oeb/reader.py @@ -373,16 +373,12 @@ class OEBReader(object): if not title: self._toc_from_navpoint(item, toc, child) continue - if not href: - gc = xpath(child, 'ncx:navPoint') - if not gc: - # This node is useless - continue - href = 'missing.html' - - href = item.abshref(urlnormalize(href[0])) + if (not href or not href[0]) and not xpath(child, 'ncx:navPoint'): + # This node is useless + continue + href = item.abshref(urlnormalize(href[0])) if href and href[0] else '' path, _ = urldefrag(href) - if path not in self.oeb.manifest.hrefs: + if href and path not in self.oeb.manifest.hrefs: self.logger.warn('TOC reference %r not found' % href) gc = xpath(child, 'ncx:navPoint') if not gc: