Skip to content

Commit a3f2020

Browse files
authored
Merge pull request #2391 from funilrys/issue-2347
Ensure that hostnames without dots are excluded.
2 parents 93f0d86 + 7e25ed0 commit a3f2020

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

testUpdateHostsFile.py

+1
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ def test_no_match(self):
842842
"128.0.0.1",
843843
"0.0.0 google",
844844
"0.1.2.3.4 foo/bar",
845+
"0.0.0.0 https"
845846
]:
846847
self.assertEqual(normalize_rule(rule, **kwargs), (None, None))
847848

updateHostsFile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ def normalize_response(
10611061
"""
10621062
first try: IP followed by domain
10631063
"""
1064-
regex = r"^\s*(\d{1,3}\.){3}\d{1,3}\s+([\w\.-]+[a-zA-Z])(.*)"
1064+
regex = r"^\s*(\d{1,3}\.){3}\d{1,3}\s+((?:\w+\.)+[a-zA-Z]+)(.*)"
10651065
result = re.search(regex, rule)
10661066

10671067
if result:
@@ -1090,7 +1090,7 @@ def normalize_response(
10901090
"""
10911091
# deny any potential IPv6 address here.
10921092
if ":" not in rule:
1093-
regex = r"^\s*([\w\.-]+[a-zA-Z])(.*)"
1093+
regex = r"^\s*((?:\w+\.)+[a-zA-Z]+)(.*)"
10941094
result = re.search(regex, rule)
10951095

10961096
if result:

0 commit comments

Comments
 (0)