diff --git a/src/calibre/srv/render_book.py b/src/calibre/srv/render_book.py index 54acfdeff3..807312a234 100644 --- a/src/calibre/srv/render_book.py +++ b/src/calibre/srv/render_book.py @@ -395,7 +395,7 @@ def transform_html(container, name, virtualize_resources, link_uid, link_to_map, href = a.get(attr) if href: href = link_replacer(name, href) - else: + elif attr in a.attrib: a.set(attr, 'javascript:void(0)') if href and href.startswith(link_uid): a.set(attr, 'javascript:void(0)') @@ -535,7 +535,7 @@ def virtualize_html(container, name, link_uid, link_to_map, virtualized_names): elif href: a.set('target', '_blank') a.set('rel', 'noopener noreferrer') - else: + elif attr in a.attrib: a.set(attr, 'javascript:void(0)') for a in link_xpath(root):