From c8db9e1c762c5d526cea327448c774b8b235891f Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Sat, 24 Mar 2018 19:42:34 +0000 Subject: [PATCH] Remove WHITELISTED, making file parsing satisfy: 1) 'dotless' hosts, e.g. localhost, cannot be blocked by a file 2) hosts ending in '.localdomain' cannot be blocked by a file --- qutebrowser/browser/adblock.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/qutebrowser/browser/adblock.py b/qutebrowser/browser/adblock.py index f0462a778..961994a9a 100644 --- a/qutebrowser/browser/adblock.py +++ b/qutebrowser/browser/adblock.py @@ -94,14 +94,8 @@ class HostBlocker: _done_count: How many files have been read successfully. _local_hosts_file: The path to the blocked-hosts file. _config_hosts_file: The path to a blocked-hosts in ~/.config - - Class attributes: - WHITELISTED: Hosts which never should be blocked. """ - WHITELISTED = ('localhost', 'localhost.localdomain', 'broadcasthost', - 'local') - def __init__(self): self._blocked_hosts = set() self._config_blocked_hosts = set() @@ -242,7 +236,7 @@ class HostBlocker: log.misc.error("Failed to parse: {!r}".format(line)) return False - if host not in self.WHITELISTED: + if '.' not in host and not host.endswith('.localdomain'): self._blocked_hosts.add(host) return True