From b676693b0cbcd72ceaf941736375614da900e4d5 Mon Sep 17 00:00:00 2001 From: Steven Black Date: Fri, 27 Jan 2023 22:45:47 -0500 Subject: [PATCH] =?UTF-8?q?Issue=20#2213:=20fix=20=E2=80=94=20deny=20IPv6?= =?UTF-8?q?=20addresses=20from=20entering=20the=20raw=20hosts=20rule=20tes?= =?UTF-8?q?t.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- updateHostsFile.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/updateHostsFile.py b/updateHostsFile.py index 537148c01..744acda5b 100755 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -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) + # deny any potential IPv6 address here. + if not ":" in rule: + regex = r"^\s*([\w\.-]+[a-zA-Z])(.*)" + result = re.search(regex, rule) - if result: - hostname, suffix = result.group(1, 2) + if result: + hostname, suffix = result.group(1, 2) + # Explicitly lowercase and trim the hostname. + hostname = hostname.lower().strip() - # 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