From c6dc9206e6cdedc74a401fc2827c1f855b945805 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 5 Oct 2018 23:37:45 +0200 Subject: [PATCH] Handle invalid QUrl objects in HostBlocker.is_blocked For some requests, we don't know a first party URL, so we get an invalid QUrl object from QtWebKit/QtWebEngine. However, the config system wants either a valid QUrl or None (for the global value), so we don't accidentally pass an invalid QUrl in. Thus, do the conversion here. --- qutebrowser/browser/adblock.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qutebrowser/browser/adblock.py b/qutebrowser/browser/adblock.py index afb7a2a18..d2a21639c 100644 --- a/qutebrowser/browser/adblock.py +++ b/qutebrowser/browser/adblock.py @@ -112,9 +112,12 @@ class HostBlocker: def is_blocked(self, url, first_party_url=None): """Check if the given URL (as QUrl) is blocked.""" + if first_party_url is not None and not first_party_url.isValid(): + first_party_url = None if not config.instance.get('content.host_blocking.enabled', url=first_party_url): return False + host = url.host() return ((host in self._blocked_hosts or host in self._config_blocked_hosts) and