Issue #2213: fix — deny IPv6 addresses from entering the raw hosts rule test.

This commit is contained in:
Steven Black
2023-01-27 22:45:47 -05:00
parent ff3e8fad81
commit b676693b0c

View File

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