Correct 2nd Iter: Ignore subject with slashes (/).
authorfunilrys <redacted>
Fri, 8 Sep 2023 16:45:30 +0000 (18:45 +0200)
committerfunilrys <redacted>
Fri, 8 Sep 2023 16:45:30 +0000 (18:45 +0200)
Upon checking the lastest release after merging #2433, I noticed
that some subjects with slashes goes through.

This patch fixes that by ignoring subjects which contains slashes.

testUpdateHostsFile.py
updateHostsFile.py

index 69a90984c29ba69793e8d2c0c8ae0954b824698c..4f580f2e246b01f3cc8788a620358abd59dba645 100644 (file)
@@ -843,6 +843,7 @@ class TestNormalizeRule(BaseStdout):
             "::1",
             "0.0.0.0 128.0.0.2",
             "0.1.2.3 foo/bar",
+            "0.3.4.5 example.org/hello/world",
             "0.0.0.0 https",
             "0.0.0.0 https..",
         ]:
index 291faa0a41e676aa5f95b29f21b71097f8e8e3fb..77e9cc844ec2c96c5185b13a0e190c21aae32b6e 100755 (executable)
@@ -1129,6 +1129,7 @@ def normalize_rule(rule, target_ip, keep_domain_comments):
             is_ip(hostname)
             or re.search(static_ip_regex, hostname)
             or "." not in hostname
+            or "/" in hostname
             or ".." in hostname
             or ":" in hostname
         ):
@@ -1147,6 +1148,7 @@ def normalize_rule(rule, target_ip, keep_domain_comments):
         not re.search(static_ip_regex, split_rule[0])
         and ":" not in split_rule[0]
         and ".." not in split_rule[0]
+        and "/" not in split_rule[0]
         and "." in split_rule[0]
     ):
         # Deny anything that looks like an IP; doesn't container dots or INVALID.
git clone https://git.99rst.org/PROJECT