Issue #2213: fix — deny IPv6 addresses from entering the raw hosts rule test.
authorSteven Black <redacted>
Sat, 28 Jan 2023 03:45:47 +0000 (22:45 -0500)
committerSteven Black <redacted>
Sat, 28 Jan 2023 03:45:47 +0000 (22:45 -0500)
updateHostsFile.py

index 537148c0135944db52b013f76ae70207bc65243a..744acda5bff019f385106459dca536f050b00a16 100755 (executable)
@@ -1062,16 +1062,17 @@ def normalize_rule(rule, target_ip, keep_domain_comments):
     """
     next try: Keep RAW domain.
     """
-    regex = r"^\s*([\w\.-]+[a-zA-Z])(.*)"
-    result = re.search(regex, rule)
-
-    if result:
-        hostname, suffix = result.group(1, 2)
+    # deny any potential IPv6 address here.
+    if not ":" in rule:
+        regex = r"^\s*([\w\.-]+[a-zA-Z])(.*)"
+        result = re.search(regex, rule)
 
-        # Explicitly lowercase and trim the hostname.
-        hostname = hostname.lower().strip()
+        if result:
+            hostname, suffix = result.group(1, 2)
+            # Explicitly lowercase and trim the hostname.
+            hostname = hostname.lower().strip()
 
-        return normalize_response(hostname, suffix)
+            return normalize_response(hostname, suffix)
 
     """
     finally, if we get here, just belch to screen
git clone https://git.99rst.org/PROJECT