mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Have abshref() return unparseable hrefs unchanged
This commit is contained in:
parent
3c26bc1075
commit
b3ec54636d
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user