Viewer: Fix a regression in the previous release that broke reading of books with mathematics and also <a> tags without href attributes. Fixes #1886192 [EPUB crashes. Cannot read property 'startswith'.](https://bugs.launchpad.net/calibre/+bug/1886192)

This commit is contained in:
Kovid Goyal 2020-07-03 20:58:11 +05:30
parent 304f682808
commit 9d7dc2e2fa
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -19,7 +19,7 @@ def get_url(mathjax_files, name):
def postprocess(link_uid): def postprocess(link_uid):
for a in document.getElementsByTagName('a'): for a in document.getElementsByTagName('a'):
href = a.getAttribute('href') href = a.getAttribute('href')
if href.startswith('#'): if href and href.startswith('#'):
a.setAttribute('href', 'javascript: void(0)') a.setAttribute('href', 'javascript: void(0)')
a.setAttribute('data-' + link_uid, JSON.stringify({'frag':href[1:]})) a.setAttribute('data-' + link_uid, JSON.stringify({'frag':href[1:]}))