From 6299aebe61644042fec79db4e36da6a3d6b8edaf Mon Sep 17 00:00:00 2001 From: funilrys Date: Tue, 13 Jul 2021 20:11:28 +0200 Subject: [PATCH 1/2] Fix whitelisting issue when RAW list are given. This patch fixes #1687. Indeed, before this patch, the whitelisting of a RAW/Plain list of domain was overlooked. --- updateHostsFile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updateHostsFile.py b/updateHostsFile.py index 1bb937c1b..4dc5a885b 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -955,7 +955,7 @@ def remove_dups_and_excl(merge_file, exclusion_regexes, output_file=None): ) for exclude in exclusions: - if re.search(r"[\s\.]" + re.escape(exclude) + r"\s", line): + if re.search(r"(^|[\s\.])" + re.escape(exclude) + r"\s", line): write_line = False break From 4f6ddfaab8065938c312c1ad9b0fb3e6e426acb1 Mon Sep 17 00:00:00 2001 From: funilrys Date: Tue, 13 Jul 2021 20:14:25 +0200 Subject: [PATCH 2/2] Blacking. --- testUpdateHostsFile.py | 8 ++++++-- updateHostsFile.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/testUpdateHostsFile.py b/testUpdateHostsFile.py index 95a275645..1f90e3898 100644 --- a/testUpdateHostsFile.py +++ b/testUpdateHostsFile.py @@ -543,7 +543,9 @@ class TestGatherCustomExclusions(BaseStdout): # Can only test in the invalid domain case # because of the settings global variable. @mock.patch("updateHostsFile.input", side_effect=["foo", "no"]) - @mock.patch("updateHostsFile.is_valid_user_provided_domain_format", return_value=False) + @mock.patch( + "updateHostsFile.is_valid_user_provided_domain_format", return_value=False + ) def test_basic(self, *_): gather_custom_exclusions("foo", []) @@ -552,7 +554,9 @@ class TestGatherCustomExclusions(BaseStdout): self.assertIn(expected, output) @mock.patch("updateHostsFile.input", side_effect=["foo", "yes", "bar", "no"]) - @mock.patch("updateHostsFile.is_valid_user_provided_domain_format", return_value=False) + @mock.patch( + "updateHostsFile.is_valid_user_provided_domain_format", return_value=False + ) def test_multiple(self, *_): gather_custom_exclusions("foo", []) diff --git a/updateHostsFile.py b/updateHostsFile.py index 4dc5a885b..4bc4a1175 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -944,7 +944,7 @@ def remove_dups_and_excl(merge_file, exclusion_regexes, output_file=None): continue # Issue #1628 - if ("@" in stripped_rule): + if "@" in stripped_rule: continue # Normalize rule