Viewer: Fix failure to open some books that contain unparseable URLs. Fixes #1858836 [Viewer Crashes on "Invalid IPv6 URL"](https://bugs.launchpad.net/calibre/+bug/1858836)

This commit is contained in:
Kovid Goyal 2020-01-09 07:17:33 +05:30
parent 39a9c123a2
commit dffc39cf0c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -106,7 +106,10 @@ def create_link_replacer(container, link_uid, changed):
return url
changed.add(base)
return resource_template.format(encode_url(base, frag))
try:
purl = urlparse(url)
except Exception:
return url
if purl.netloc or purl.query:
return url
if purl.scheme and purl.scheme != 'file':