diff --git a/src/calibre/ebooks/html/input.py b/src/calibre/ebooks/html/input.py index e958b9dd27..ccbc987533 100644 --- a/src/calibre/ebooks/html/input.py +++ b/src/calibre/ebooks/html/input.py @@ -148,7 +148,11 @@ class HTMLFile(object): url = match.group(i) if url: break - link = self.resolve(url) + try: + link = self.resolve(url) + except ValueError: + # Unparseable URL, ignore + continue if link not in self.links: self.links.append(link) diff --git a/src/calibre/ebooks/mobi/writer2/serializer.py b/src/calibre/ebooks/mobi/writer2/serializer.py index 041a9922cb..5bf6b10d23 100644 --- a/src/calibre/ebooks/mobi/writer2/serializer.py +++ b/src/calibre/ebooks/mobi/writer2/serializer.py @@ -178,7 +178,11 @@ class Serializer(object): at the end. ''' hrefs = self.oeb.manifest.hrefs - path, frag = urldefrag(urlnormalize(href)) + try: + path, frag = urldefrag(urlnormalize(href)) + except ValueError: + # Unparseable URL + return False if path and base: path = base.abshref(path) if path and path not in hrefs: diff --git a/src/calibre/ebooks/oeb/transforms/split.py b/src/calibre/ebooks/oeb/transforms/split.py index 24af1aa4f7..96e4b08079 100644 --- a/src/calibre/ebooks/oeb/transforms/split.py +++ b/src/calibre/ebooks/oeb/transforms/split.py @@ -154,7 +154,11 @@ class Split(object): def rewrite_links(self, url): href, frag = urldefrag(url) - href = self.current_item.abshref(href) + try: + href = self.current_item.abshref(href) + except ValueError: + # Unparseable URL + return url if href in self.map: anchor_map = self.map[href] nhref = anchor_map[frag if frag else None]