No functional changes.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
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