From 384054e2b971dcdd0616bc7b96896e5010c170f9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 21 Oct 2014 08:56:03 +0530 Subject: [PATCH] Conversion: Ignore un-parseable links when trying to generate ToC from links, instead of aborting the conversion. Fixes #1383365 [Ipv6 error when converting PDF to MOBI](https://bugs.launchpad.net/calibre/+bug/1383365) --- src/calibre/ebooks/oeb/transforms/structure.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/transforms/structure.py b/src/calibre/ebooks/oeb/transforms/structure.py index 2e0c62e82b..3c8f0e5efd 100644 --- a/src/calibre/ebooks/oeb/transforms/structure.py +++ b/src/calibre/ebooks/oeb/transforms/structure.py @@ -206,7 +206,11 @@ class DetectStructure(object): for item in self.oeb.spine: for a in XPath('//h:a[@href]')(item.data): href = a.get('href') - purl = urlparse(href) + try: + purl = urlparse(href) + except ValueError: + self.log.warning('Ignoring malformed URL:', href) + continue if not purl[0] or purl[0] == 'file': href, frag = purl.path, purl.fragment href = item.abshref(href)