summaryrefslogtreecommitdiff
path: root/qutebrowser/components/hostblock.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-06-24 19:57:03 +0200
committerFlorian Bruhin <me@the-compiler.org>2021-06-24 19:57:03 +0200
commitc580ebf0801e5a3ecabc54f327498bb753c6d5f2 (patch)
tree3e6e4ac0ae1de93fde1f93821733e7b58ae3091a /qutebrowser/components/hostblock.py
parent0b8cc812fd0b73e296a3f93db02ce5d0b35714fc (diff)
parentd5433702a5c5c8e2ac831929a304b21570366dba (diff)
downloadqutebrowser-c580ebf0801e5a3ecabc54f327498bb753c6d5f2.tar.gz
qutebrowser-c580ebf0801e5a3ecabc54f327498bb753c6d5f2.zip
Merge remote-tracking branch 'origin/pr/6372'
Diffstat (limited to 'qutebrowser/components/hostblock.py')
-rw-r--r--qutebrowser/components/hostblock.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/qutebrowser/components/hostblock.py b/qutebrowser/components/hostblock.py
index 8a0174584..0e7278d1b 100644
--- a/qutebrowser/components/hostblock.py
+++ b/qutebrowser/components/hostblock.py
@@ -37,7 +37,10 @@ from qutebrowser.api import (
qtutils,
)
from qutebrowser.components.utils import blockutils
-from qutebrowser.utils import version # FIXME: Move needed parts into api namespace?
+from qutebrowser.utils import ( # FIXME: Move needed parts into api namespace?
+ urlutils,
+ version
+)
logger = logging.getLogger("network")
@@ -124,10 +127,17 @@ 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 urlutils.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."""