diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index d6377dbf52..36c46a81c0 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -1108,7 +1108,10 @@ class Manifest(object): """Convert the URL provided in :param:`href` from a reference relative to this manifest item to a book-absolute reference. """ - purl = urlparse(href) + try: + purl = urlparse(href) + except ValueError: + return href scheme = purl.scheme if scheme and scheme != 'file': return href diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index b38a0babe2..198cfae728 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -97,7 +97,10 @@ def name_to_href(name, root, base=None, quote=urlquote): def href_to_name(href, root, base=None): base = root if base is None else os.path.dirname(name_to_abspath(base, root)) - purl = urlparse(href) + try: + purl = urlparse(href) + except ValueError: + return None if purl.scheme or not purl.path: return None href = urlunquote(purl.path) @@ -1458,5 +1461,3 @@ def test_roundtrip(): if __name__ == '__main__': test_roundtrip() - -