Handle invalid URLs in acceptNavigationRequest in the tab API
This commit is contained in:
parent
4c23fb9e2f
commit
ee06ba0140
@ -854,12 +854,20 @@ class AbstractTab(QWidget):
|
||||
navigation.navigation_type,
|
||||
navigation.is_main_frame))
|
||||
|
||||
if (navigation.navigation_type == navigation.Type.link_clicked and
|
||||
not navigation.url.isValid()):
|
||||
if not navigation.url.isValid():
|
||||
# Also a WORKAROUND for missing IDNA 2008 support in QUrl, see
|
||||
# https://bugreports.qt.io/browse/QTBUG-60364
|
||||
|
||||
if navigation.navigation_type == navigation.Type.link_clicked:
|
||||
msg = urlutils.get_errstring(navigation.url,
|
||||
"Invalid link clicked")
|
||||
message.error(msg)
|
||||
self.data.open_target = usertypes.ClickTarget.normal
|
||||
|
||||
log.webview.debug("Ignoring invalid URL {} in "
|
||||
"acceptNavigationRequest: {}".format(
|
||||
navigation.url.toDisplayString(),
|
||||
navigation.url.errorString()))
|
||||
navigation.accepted = False
|
||||
|
||||
def handle_auto_insert_mode(self, ok):
|
||||
|
@ -242,14 +242,6 @@ class WebEnginePage(QWebEnginePage):
|
||||
typ: QWebEnginePage.NavigationType,
|
||||
is_main_frame: bool):
|
||||
"""Override acceptNavigationRequest to forward it to the tab API."""
|
||||
if not url.isValid():
|
||||
# WORKAROUND for missing IDNA 2008 support in QUrl
|
||||
# see https://bugreports.qt.io/browse/QTBUG-60364
|
||||
log.webview.debug("Ignoring invalid URL {} in "
|
||||
"acceptNavigationRequest: {}".format(
|
||||
url.toDisplayString(), url.errorString()))
|
||||
return True
|
||||
|
||||
type_map = {
|
||||
QWebEnginePage.NavigationTypeLinkClicked:
|
||||
usertypes.NavigationRequest.Type.link_clicked,
|
||||
|
Loading…
Reference in New Issue
Block a user