diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 13095e98f..d1890bcb6 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -85,6 +85,8 @@ Fixed - The outdated header `X-Do-Not-Track` is no longer sent. - A javascript error on page load when using Qt 5.12 was fixed. - `window.print()` works with Qt 5.12 now. +- PAC proxies were never correctly supported with QtWebEngine, but are now + explicitly disallowed. v1.5.2 ------ diff --git a/qutebrowser/browser/network/pac.py b/qutebrowser/browser/network/pac.py index bd060820b..47bb1e537 100644 --- a/qutebrowser/browser/network/pac.py +++ b/qutebrowser/browser/network/pac.py @@ -208,6 +208,8 @@ class PACResolver: Return: A list of QNetworkProxy objects in order of preference. """ + qtutils.ensure_valid(query.url()) + if from_file: string_flags = QUrl.PrettyDecoded else: diff --git a/qutebrowser/browser/network/proxy.py b/qutebrowser/browser/network/proxy.py index d3e25c23c..f5685ea25 100644 --- a/qutebrowser/browser/network/proxy.py +++ b/qutebrowser/browser/network/proxy.py @@ -20,10 +20,12 @@ """Handling of proxies.""" +from PyQt5.QtCore import QUrl from PyQt5.QtNetwork import QNetworkProxy, QNetworkProxyFactory from qutebrowser.config import config, configtypes -from qutebrowser.utils import objreg +from qutebrowser.utils import objreg, message, usertypes, urlutils +from qutebrowser.misc import objects from qutebrowser.browser.network import pac @@ -33,6 +35,18 @@ def init(): objreg.register('proxy-factory', proxy_factory) QNetworkProxyFactory.setApplicationProxyFactory(proxy_factory) + config.instance.changed.connect(_warn_for_pac) + _warn_for_pac() + + +@config.change_filter('content.proxy', function=True) +def _warn_for_pac(): + """Show a warning if PAC is used with QtWebEngine.""" + proxy = config.val.content.proxy + if (isinstance(proxy, pac.PACFetcher) and + objects.backend == usertypes.Backend.QtWebEngine): + message.error("PAC support isn't implemented for QtWebEngine yet!") + def shutdown(): QNetworkProxyFactory.setApplicationProxyFactory(None) @@ -70,7 +84,11 @@ class ProxyFactory(QNetworkProxyFactory): # ref. http://doc.qt.io/qt-5/qnetworkproxyfactory.html#systemProxyForQuery proxies = QNetworkProxyFactory.systemProxyForQuery(query) elif isinstance(proxy, pac.PACFetcher): - proxies = proxy.resolve(query) + if objects.backend == usertypes.Backend.QtWebEngine: + # Looks like query.url() is always invalid on QtWebEngine... + proxies = [urlutils.proxy_from_url(QUrl('direct://'))] + else: + proxies = proxy.resolve(query) else: proxies = [proxy] for p in proxies: