From 7e1b06ecf9b732816b098cfef5d1882b6c8c04b4 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Mon, 19 Jun 2017 20:23:00 -0500 Subject: [PATCH] Tighten regex rule to discard IP address as hostname --- updateHostsFile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/updateHostsFile.py b/updateHostsFile.py index 4de7f3eb0..59c9b6d61 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -501,7 +501,8 @@ def normalize_rule(rule): The rule string with spelling and spacing reformatted. """ - result = re.search(r'^[ \t]*(\d+\.\d+\.\d+\.\d+)\s+([\w\.-]+)(.*)', rule) + result = re.search(r'^\s*(\d{1,3}\.){3}\d{1,3}\s+([\w\.-]+[a-zA-Z])(.*)', + rule) if result: hostname, suffix = result.group(2, 3)