From dffc39cf0cb73aa1302f2e26a8551cdfe4da3595 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Jan 2020 07:17:33 +0530 Subject: [PATCH] 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) --- src/calibre/srv/render_book.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/srv/render_book.py b/src/calibre/srv/render_book.py index 4e0c5fb6bd..56b6802d88 100644 --- a/src/calibre/srv/render_book.py +++ b/src/calibre/srv/render_book.py @@ -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)) - purl = urlparse(url) + try: + purl = urlparse(url) + except Exception: + return url if purl.netloc or purl.query: return url if purl.scheme and purl.scheme != 'file':