Issue #2785: fix — ignore domains ending with a dot.
authorSteven Black <redacted>
Tue, 17 Dec 2024 00:53:49 +0000 (20:53 -0400)
committerSteven Black <redacted>
Tue, 17 Dec 2024 00:53:49 +0000 (20:53 -0400)
testUpdateHostsFile.py
updateHostsFile.py

index 4f580f2e246b01f3cc8788a620358abd59dba645..3dfa76f43382461281ae9201f1ab6119b4e3d27f 100644 (file)
@@ -846,6 +846,7 @@ class TestNormalizeRule(BaseStdout):
             "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))
 
index c31ed79bd3a09ea5dc676a137aa74f0142e00309..059cb731c190534d7b1d78cd463b4f67825ef9fc 100755 (executable)
@@ -1129,8 +1129,9 @@ def normalize_rule(rule, target_ip, keep_domain_comments):
             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
@@ -1138,6 +1139,9 @@ def normalize_rule(rule, target_ip, keep_domain_comments):
             # 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)
git clone https://git.99rst.org/PROJECT