From: Indrajit Raychaudhuri Date: Tue, 20 Jun 2017 01:23:00 +0000 (-0500) Subject: Tighten regex rule to discard IP address as hostname X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=7e1b06ecf9b732816b098cfef5d1882b6c8c04b4;p=stevenblack-hosts.git Tighten regex rule to discard IP address as hostname --- 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)