Don't emit predicted_navigation with invalid URLs

Fixes #3706
This commit is contained in:
Florian Bruhin 2018-03-13 09:46:09 +01:00
parent dcd6bcd2f4
commit 1c9598d2c0
3 changed files with 9 additions and 3 deletions

View File

@ -706,7 +706,9 @@ class WebEngineTab(browsertab.AbstractTab):
self._widget.shutdown() self._widget.shutdown()
def reload(self, *, force=False): def reload(self, *, force=False):
self.predicted_navigation.emit(self.url()) if self.url().isValid():
self.predicted_navigation.emit(self.url())
if force: if force:
action = QWebEnginePage.ReloadAndBypassCache action = QWebEnginePage.ReloadAndBypassCache
else: else:
@ -931,6 +933,7 @@ class WebEngineTab(browsertab.AbstractTab):
@pyqtSlot(QUrl) @pyqtSlot(QUrl)
def _on_predicted_navigation(self, url): def _on_predicted_navigation(self, url):
"""If we know we're going to visit an URL soon, change the settings.""" """If we know we're going to visit an URL soon, change the settings."""
qtutils.ensure_valid(url)
self.settings.update_for_url(url) self.settings.update_for_url(url)
@pyqtSlot(usertypes.NavigationRequest) @pyqtSlot(usertypes.NavigationRequest)

View File

@ -701,7 +701,9 @@ class WebKitTab(browsertab.AbstractTab):
self._widget.shutdown() self._widget.shutdown()
def reload(self, *, force=False): def reload(self, *, force=False):
self.predicted_navigation.emit(self.url()) if self.url().isValid():
self.predicted_navigation.emit(self.url())
if force: if force:
action = QWebPage.ReloadAndBypassCache action = QWebPage.ReloadAndBypassCache
else: else:

View File

@ -22,7 +22,7 @@
from PyQt5.QtGui import QFont from PyQt5.QtGui import QFont
from qutebrowser.config import config, configutils from qutebrowser.config import config, configutils
from qutebrowser.utils import log, usertypes, urlmatch from qutebrowser.utils import log, usertypes, urlmatch, qtutils
from qutebrowser.misc import objects from qutebrowser.misc import objects
UNSET = object() UNSET = object()
@ -141,6 +141,7 @@ class AbstractSettings:
Return: Return:
A set of settings which actually changed. A set of settings which actually changed.
""" """
qtutils.ensure_valid(url)
changed_settings = set() changed_settings = set()
for values in config.instance: for values in config.instance:
if not values.opt.supports_pattern: if not values.opt.supports_pattern: