E-book viewer: Fix clicking on links with empty destinations hanging the viewer. Fixes #2034404 [E-book viewer: error navigating calibre User Manual](https://bugs.launchpad.net/calibre/+bug/2034404)

This commit is contained in:
Kovid Goyal 2023-09-06 23:05:17 +05:30
parent e01740cf8a
commit 298c6fe3e0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -395,6 +395,8 @@ def transform_html(container, name, virtualize_resources, link_uid, link_to_map,
href = a.get(attr)
if href:
href = link_replacer(name, href)
else:
a.set(attr, 'javascript:void(0)')
if href and href.startswith(link_uid):
a.set(attr, 'javascript:void(0)')
parts = href.split('|')
@ -533,6 +535,8 @@ def virtualize_html(container, name, link_uid, link_to_map, virtualized_names):
elif href:
a.set('target', '_blank')
a.set('rel', 'noopener noreferrer')
else:
a.set(attr, 'javascript:void(0)')
for a in link_xpath(root):
handle_link(a)