mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
E-book viewer: Fix links with an href of # not working. Fixes #1915303 [Private bug](https://bugs.launchpad.net/calibre/+bug/1915303)
This commit is contained in:
parent
dcf658b365
commit
7d5bb8524d
@ -100,9 +100,9 @@ def create_link_replacer(container, link_uid, changed):
|
|||||||
def link_replacer(base, url):
|
def link_replacer(base, url):
|
||||||
if url.startswith('#'):
|
if url.startswith('#'):
|
||||||
frag = urlunquote(url[1:])
|
frag = urlunquote(url[1:])
|
||||||
if not frag:
|
|
||||||
return url
|
|
||||||
changed.add(base)
|
changed.add(base)
|
||||||
|
if not frag:
|
||||||
|
return link_uid
|
||||||
return resource_template.format(encode_url(base, frag))
|
return resource_template.format(encode_url(base, frag))
|
||||||
try:
|
try:
|
||||||
purl = urlparse(url)
|
purl = urlparse(url)
|
||||||
@ -440,10 +440,12 @@ def transform_html(container, name, virtualize_resources, link_uid, link_to_map,
|
|||||||
href = link_replacer(name, href)
|
href = link_replacer(name, href)
|
||||||
if href and href.startswith(link_uid):
|
if href and href.startswith(link_uid):
|
||||||
a.set(attr, 'javascript:void(0)')
|
a.set(attr, 'javascript:void(0)')
|
||||||
parts = decode_url(href.split('|')[1])
|
parts = href.split('|')
|
||||||
lname, lfrag = parts[0], parts[1]
|
if len(parts) > 1:
|
||||||
link_to_map.setdefault(lname, {}).setdefault(lfrag or '', set()).add(name)
|
parts = decode_url(parts[1])
|
||||||
a.set('data-' + link_uid, json.dumps({'name':lname, 'frag':lfrag}, ensure_ascii=False))
|
lname, lfrag = parts[0], parts[1]
|
||||||
|
link_to_map.setdefault(lname, {}).setdefault(lfrag or '', set()).add(name)
|
||||||
|
a.set('data-' + link_uid, json.dumps({'name':lname, 'frag':lfrag}, ensure_ascii=False))
|
||||||
|
|
||||||
for a in link_xpath(root):
|
for a in link_xpath(root):
|
||||||
handle_link(a)
|
handle_link(a)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user