git.99rst.org
/
stevenblack-hosts.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
| inline |
side by side
(parent:
93f0d86
)
Ensure that hostnames without dots are excluded.
author
funilrys
<redacted>
Wed, 26 Jul 2023 13:06:21 +0000
(15:06 +0200)
committer
funilrys
<redacted>
Wed, 26 Jul 2023 13:06:21 +0000
(15:06 +0200)
This patch fixes #2347.
testUpdateHostsFile.py
patch
|
blob
|
history
updateHostsFile.py
patch
|
blob
|
history
diff --git
a/testUpdateHostsFile.py
b/testUpdateHostsFile.py
index 12fe695fb964e9814d7bbd4960bfd56ce6121291..7b3ff3a49f6d47ff6d82f5bd0405e1f0f758d0be 100644
(file)
--- a/
testUpdateHostsFile.py
+++ b/
testUpdateHostsFile.py
@@
-842,6
+842,7
@@
class TestNormalizeRule(BaseStdout):
"128.0.0.1",
"0.0.0 google",
"0.1.2.3.4 foo/bar",
+ "0.0.0.0 https"
]:
self.assertEqual(normalize_rule(rule, **kwargs), (None, None))
diff --git
a/updateHostsFile.py
b/updateHostsFile.py
index 5c8271492cf70845f40d87437ee5914910ce4847..986f2023a3737ba7e32f7926c864381b37cbfcc3 100755
(executable)
--- a/
updateHostsFile.py
+++ b/
updateHostsFile.py
@@
-1061,7
+1061,7
@@
def normalize_rule(rule, target_ip, keep_domain_comments):
"""
first try: IP followed by domain
"""
- regex = r"^\s*(\d{1,3}\.){3}\d{1,3}\s+(
[\w\.-]+[a-zA-Z]
)(.*)"
+ regex = r"^\s*(\d{1,3}\.){3}\d{1,3}\s+(
(?:\w+\.)+[a-zA-Z]+
)(.*)"
result = re.search(regex, rule)
if result:
@@
-1090,7
+1090,7
@@
def normalize_rule(rule, target_ip, keep_domain_comments):
"""
# deny any potential IPv6 address here.
if ":" not in rule:
- regex = r"^\s*(
[\w\.-]+[a-zA-Z]
)(.*)"
+ regex = r"^\s*(
(?:\w+\.)+[a-zA-Z]+
)(.*)"
result = re.search(regex, rule)
if result:
git clone https://git.99rst.org/PROJECT