From 102b789a3bb89e44e8181d752e8ddb9dd318d38f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 10 Dec 2025 17:10:49 +0000 Subject: [PATCH] util: Refactor is_fqdn No functional changes. Signed-off-by: Michael Tremer --- src/dnsbl/util.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dnsbl/util.py b/src/dnsbl/util.py index 02924dd..126984c 100644 --- a/src/dnsbl/util.py +++ b/src/dnsbl/util.py @@ -93,14 +93,14 @@ def is_fqdn(s): return False # Remove final dot - if s.endswith("."): - s = s[:-1] + s = s.removesuffix(".") - labels = s.split(".") - - for label in labels: + for label in s.split("."): + # Labels cannot be empty and must be shorter than 64 characters if not 1 <= len(label) <= 63: return False + + # Labels my only contain alpha-numerical characters as well as dash and underscore for ch in label: if not ch.isalnum() or ch in "-_": return False -- 2.47.3