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)

This commit is contained in:
Kovid Goyal 2014-10-21 08:56:03 +05:30
parent d2df60ebce
commit 384054e2b9

View File

@ -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)