Skip to content

Commit 080d276

Browse files
committed
Issue #2785: fix — ignore domains ending with a dot.
1 parent 7c8c1fb commit 080d276

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

testUpdateHostsFile.py

+1
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ def test_no_match(self):
846846
"0.3.4.5 example.org/hello/world",
847847
"0.0.0.0 https",
848848
"0.0.0.0 https..",
849+
"0.0.0.0 foo.",
849850
]:
850851
self.assertEqual(normalize_rule(rule, **kwargs), (None, None))
851852

updateHostsFile.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1129,15 +1129,19 @@ def belch_unwanted(unwanted: str) -> Tuple[None, None]:
11291129
is_ip(hostname)
11301130
or re.search(static_ip_regex, hostname)
11311131
or "." not in hostname
1132-
or "/" in hostname
11331132
or ".." in hostname
1133+
or "." in hostname[-1]
1134+
or "/" in hostname
11341135
or ":" in hostname
11351136
):
11361137
# Example: 0.0.0.0 127.0.0.1
11371138

11381139
# If the hostname is:
11391140
# - an IP - or looks like it,
11401141
# - doesn't contain dots, or
1142+
# - contains repeated dots,
1143+
# - ends in a dot, or
1144+
# - contains a slash, or
11411145
# - contains a colon,
11421146
# we don't want to normalize it.
11431147
return belch_unwanted(rule)

0 commit comments

Comments
 (0)