'suffix' in regex matches empty string on all the data files, except
authorqqo <redacted>
Fri, 23 Oct 2015 22:43:18 +0000 (01:43 +0300)
committerqqo <redacted>
Fri, 23 Oct 2015 22:43:18 +0000 (01:43 +0300)
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

index 2108a4f783ce0a4eb42940fbf9dfca86ceda31a1..63af4e7e008c1611aff604b0cb600662ec007703 100755 (executable)
@@ -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
 
git clone https://git.99rst.org/PROJECT