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.navigation_type,
|
||||||
navigation.is_main_frame))
|
navigation.is_main_frame))
|
||||||
|
|
||||||
if (navigation.navigation_type == navigation.Type.link_clicked and
|
if not navigation.url.isValid():
|
||||||
not navigation.url.isValid()):
|
# Also a WORKAROUND for missing IDNA 2008 support in QUrl, see
|
||||||
msg = urlutils.get_errstring(navigation.url,
|
# https://bugreports.qt.io/browse/QTBUG-60364
|
||||||
"Invalid link clicked")
|
|
||||||
message.error(msg)
|
if navigation.navigation_type == navigation.Type.link_clicked:
|
||||||
self.data.open_target = usertypes.ClickTarget.normal
|
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
|
navigation.accepted = False
|
||||||
|
|
||||||
def handle_auto_insert_mode(self, ok):
|
def handle_auto_insert_mode(self, ok):
|
||||||
|
@ -242,14 +242,6 @@ class WebEnginePage(QWebEnginePage):
|
|||||||
typ: QWebEnginePage.NavigationType,
|
typ: QWebEnginePage.NavigationType,
|
||||||
is_main_frame: bool):
|
is_main_frame: bool):
|
||||||
"""Override acceptNavigationRequest to forward it to the tab API."""
|
"""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 = {
|
type_map = {
|
||||||
QWebEnginePage.NavigationTypeLinkClicked:
|
QWebEnginePage.NavigationTypeLinkClicked:
|
||||||
usertypes.NavigationRequest.Type.link_clicked,
|
usertypes.NavigationRequest.Type.link_clicked,
|
||||||
|
Loading…
Reference in New Issue
Block a user