Stylistic changes to is_whitelisted_domain
This commit is contained in:
parent
ccdb59cce1
commit
523e071a97
@ -25,7 +25,6 @@ import functools
|
|||||||
import posixpath
|
import posixpath
|
||||||
import zipfile
|
import zipfile
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import re
|
|
||||||
|
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
from qutebrowser.utils import objreg, standarddir, log, message
|
from qutebrowser.utils import objreg, standarddir, log, message
|
||||||
@ -67,14 +66,12 @@ def is_whitelisted_domain(host):
|
|||||||
Args:
|
Args:
|
||||||
host: The host as given by the adblocker as string.
|
host: The host as given by the adblocker as string.
|
||||||
"""
|
"""
|
||||||
whitelist = objreg.get('config').get('content', 'host-blocking-whitelist')
|
whitelist = config.get('content', 'host-blocking-whitelist')
|
||||||
if whitelist is None:
|
if whitelist is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for domain in whitelist:
|
for pattern in whitelist:
|
||||||
fnmatch_translated = fnmatch.translate(domain)
|
if fnmatch.fnmatch(host, pattern.lower()):
|
||||||
domain_regex = re.compile(fnmatch_translated, re.IGNORECASE)
|
|
||||||
if domain_regex.match(host):
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user