]> git.ipfire.org Git - dnsbl.git/commitdiff
util: Be more lax with domain names
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 10 Dec 2025 17:10:01 +0000 (17:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 10 Dec 2025 17:10:01 +0000 (17:10 +0000)
There are a lot of domain names out there that start/end with a
non-alphanumerical character which is why we need to remove this check.

We also need to accept underscores in domain names.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dnsbl/util.py

index 0e828d1f1308406f03bc367ac09b3278ddb51db4..02924dde8c374f42bbffaf7761cb6b48c19bed70 100644 (file)
@@ -101,10 +101,8 @@ def is_fqdn(s):
        for label in labels:
                if not 1 <= len(label) <= 63:
                        return False
-               if not label[0].isalnum() or not label[-1].isalnum():
-                       return False
                for ch in label:
-                       if not (ch.isalnum() or ch == "-"):
+                       if not ch.isalnum() or ch in "-_":
                                return False
 
        return True