diff options
author | Ander Punnar <ander@kvlt.ee> | 2021-04-07 23:34:58 +0300 |
---|---|---|
committer | Ander Punnar <ander@kvlt.ee> | 2021-04-08 00:31:31 +0300 |
commit | c0a55c1f755c51cf37ce26431db98bf42631631e (patch) | |
tree | a65f97aeeb6e32f2ae902b9e8677025803ab1c65 /qutebrowser/components | |
parent | 1a383bb6701ad497a9f7868d4b5f60fd99a4e98e (diff) | |
download | qutebrowser-c0a55c1f755c51cf37ce26431db98bf42631631e.tar.gz qutebrowser-c0a55c1f755c51cf37ce26431db98bf42631631e.zip |
block subdomains of blocked hosts
Diffstat (limited to 'qutebrowser/components')
-rw-r--r-- | qutebrowser/components/hostblock.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/qutebrowser/components/hostblock.py b/qutebrowser/components/hostblock.py index 8a0174584..e19536744 100644 --- a/qutebrowser/components/hostblock.py +++ b/qutebrowser/components/hostblock.py @@ -37,6 +37,7 @@ from qutebrowser.api import ( qtutils, ) from qutebrowser.components.utils import blockutils +from qutebrowser.config.configutils import _widened_hostnames from qutebrowser.utils import version # FIXME: Move needed parts into api namespace? @@ -124,10 +125,16 @@ class HostBlocker: if not config.get("content.blocking.enabled", url=first_party_url): return False + if blockutils.is_whitelisted_url(request_url): + return False + host = request_url.host() - return ( - host in self._blocked_hosts or host in self._config_blocked_hosts - ) and not blockutils.is_whitelisted_url(request_url) + + for hostname in _widened_hostnames(host): + if hostname in self._blocked_hosts or hostname in self._config_blocked_hosts: + return True + + return False def filter_request(self, info: interceptor.Request) -> None: """Block the given request if necessary.""" |