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.
This commit is contained in:
parent
14957c75ff
commit
c6dc9206e6
@ -112,9 +112,12 @@ class HostBlocker:
|
|||||||
|
|
||||||
def is_blocked(self, url, first_party_url=None):
|
def is_blocked(self, url, first_party_url=None):
|
||||||
"""Check if the given URL (as QUrl) is blocked."""
|
"""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',
|
if not config.instance.get('content.host_blocking.enabled',
|
||||||
url=first_party_url):
|
url=first_party_url):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
host = url.host()
|
host = url.host()
|
||||||
return ((host in self._blocked_hosts or
|
return ((host in self._blocked_hosts or
|
||||||
host in self._config_blocked_hosts) and
|
host in self._config_blocked_hosts) and
|
||||||
|
Loading…
Reference in New Issue
Block a user