Skip to content

Commit

Permalink
Issue #2785: fix — ignore domains ending with a dot.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenBlack committed Dec 17, 2024
1 parent 7c8c1fb commit 080d276
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions testUpdateHostsFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ def test_no_match(self):
"0.3.4.5 example.org/hello/world",
"0.0.0.0 https",
"0.0.0.0 https..",
"0.0.0.0 foo.",
]:
self.assertEqual(normalize_rule(rule, **kwargs), (None, None))

Expand Down
6 changes: 5 additions & 1 deletion updateHostsFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,15 +1129,19 @@ def belch_unwanted(unwanted: str) -> Tuple[None, None]:
is_ip(hostname)
or re.search(static_ip_regex, hostname)
or "." not in hostname
or "/" in hostname
or ".." in hostname
or "." in hostname[-1]
or "/" in hostname
or ":" in hostname
):
# Example: 0.0.0.0 127.0.0.1

# If the hostname is:
# - an IP - or looks like it,
# - doesn't contain dots, or
# - contains repeated dots,
# - ends in a dot, or
# - contains a slash, or
# - contains a colon,
# we don't want to normalize it.
return belch_unwanted(rule)
Expand Down

0 comments on commit 080d276

Please sign in to comment.