Only open external URLs in response to clicks. Fixes #1908041 [ebook-viewer and ebook-edit: iFrame in ePub opens browser](https://bugs.launchpad.net/calibre/+bug/1908041)

This commit is contained in:
Kovid Goyal 2020-12-15 08:10:54 +05:30
parent 8aa354729d
commit a73fd36476
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 3 deletions

View File

@ -25,7 +25,7 @@ from calibre.constants import (
)
from calibre.ebooks.oeb.base import OEB_DOCS, XHTML_MIME, serialize
from calibre.ebooks.oeb.polish.parsing import parse
from calibre.gui2 import NO_URL_FORMATTING, error_dialog, is_dark_theme, open_url
from calibre.gui2 import NO_URL_FORMATTING, error_dialog, is_dark_theme, safe_open_url
from calibre.gui2.palette import dark_color, dark_link_color, dark_text_color
from calibre.gui2.tweak_book import TOP, actions, current_container, editors, tprefs
from calibre.gui2.tweak_book.file_list import OpenWithHandler
@ -319,7 +319,8 @@ class WebPage(QWebEnginePage):
return True
if url.scheme() in (FAKE_PROTOCOL, 'data'):
return True
open_url(url)
if req_type == QWebEnginePage.NavigationType.NavigationTypeLinkClicked:
safe_open_url(url)
return False
def go_to_anchor(self, anchor):

View File

@ -369,7 +369,7 @@ class WebPage(QWebEnginePage):
return True
if url.scheme() in (FAKE_PROTOCOL, 'data'):
return True
if url.scheme() in ('http', 'https'):
if url.scheme() in ('http', 'https') and req_type == QWebEnginePage.NavigationType.NavigationTypeLinkClicked:
safe_open_url(url)
prints('Blocking navigation request to:', url.toString())
return False