From d810d251782ad64db31d0f4d18c777e61cabd026 Mon Sep 17 00:00:00 2001 From: qqo Date: Sat, 24 Oct 2015 00:58:12 +0300 Subject: [PATCH 1/2] Explicitly lowercase hostname to prevent mixed-case duplicates. --- updateHostsFile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/updateHostsFile.py b/updateHostsFile.py index e153d71b6..2108a4f78 100755 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -188,6 +188,7 @@ def normalizeRule(rule): result = re.search(r'^[ \t]*(\d+\.\d+\.\d+\.\d+)\s+([\w\.-]+)(.*)',rule) if result: target, hostname, suffix = result.groups() + hostname = hostname.lower() # explicitly lowercase hostname return hostname, "%s %s %s\n" % (TARGET_HOST, hostname, suffix) print '==>%s<==' % rule return None, None From 10c4449774262de5079b344b0153115529be356d Mon Sep 17 00:00:00 2001 From: qqo Date: Sat, 24 Oct 2015 01:43:18 +0300 Subject: [PATCH 2/2] 'suffix' in regex matches empty string on all the data files, except one (incorrect) line containing port: 0.0.0.0 telemetry.appex.bing.net:443 The resulting entry in hosts file generated like this: 0.0.0.0 telemetry.appex.bing.net :443 which is incorrect. The bug was not spotted only because the incorrect line in the data source was after the correct line without port, thus it was ignored and not added to resulting hosts file. --- updateHostsFile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/updateHostsFile.py b/updateHostsFile.py index 2108a4f78..63af4e7e0 100755 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -189,7 +189,11 @@ def normalizeRule(rule): if result: target, hostname, suffix = result.groups() hostname = hostname.lower() # explicitly lowercase hostname - return hostname, "%s %s %s\n" % (TARGET_HOST, hostname, suffix) + if suffix is not '': + # add suffix as comment only, not as a separate host + return hostname, "%s %s #%s\n" % (TARGET_HOST, hostname, suffix) + else: + return hostname, "%s %s\n" % (TARGET_HOST, hostname) print '==>%s<==' % rule return None, None