From b1506274c52f2ea84562407a72c3678868c180b3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 7 Jun 2018 16:03:25 +0200 Subject: [PATCH] Implement a better workaround for chrome-error:// URLs It looks like chrome-error://chromewebdata/ triggers another invalid scheme load which is why the endless loop happens. When we install a custom scheme handler for chrome-error:// we can at least show an error page. --- qutebrowser/browser/webengine/webenginequtescheme.py | 11 ++++++++++- qutebrowser/browser/webengine/webenginetab.py | 6 ------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/qutebrowser/browser/webengine/webenginequtescheme.py b/qutebrowser/browser/webengine/webenginequtescheme.py index ac583a671..80269ba85 100644 --- a/qutebrowser/browser/webengine/webenginequtescheme.py +++ b/qutebrowser/browser/webengine/webenginequtescheme.py @@ -19,7 +19,7 @@ """QtWebEngine specific qute://* handlers and glue code.""" -from PyQt5.QtCore import QBuffer, QIODevice +from PyQt5.QtCore import QBuffer, QIODevice, QUrl from PyQt5.QtWebEngineCore import (QWebEngineUrlSchemeHandler, QWebEngineUrlRequestJob) @@ -34,6 +34,9 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler): def install(self, profile): """Install the handler for qute:// URLs on the given profile.""" profile.installUrlSchemeHandler(b'qute', self) + if qtutils.version_check('5.11', compiled=False): + # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378 + profile.installUrlSchemeHandler(b'chrome-error', self) def requestStarted(self, job): """Handle a request for a qute: scheme. @@ -45,6 +48,12 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler): job: QWebEngineUrlRequestJob """ url = job.requestUrl() + + if url.scheme() == 'chrome-error': + # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378 + job.fail(QWebEngineUrlRequestJob.UrlInvalid) + return + assert job.requestMethod() == b'GET' assert url.scheme() == 'qute' log.misc.debug("Got request for {}".format(url.toDisplayString())) diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index fa2edf53e..6a60cdce0 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -1030,12 +1030,6 @@ class WebEngineTab(browsertab.AbstractTab): if not ok and not js_enabled: self.dump_async(self._error_page_workaround) - if (not ok and - self.url() == QUrl('chrome-error://chromewebdata/') and - qtutils.version_check('5.11', compiled=False)): - # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378 - self._show_error_page(QUrl(), "Unknown URL scheme") - if ok and self._reload_url is not None: # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-66656 log.config.debug(