From fa91642b6ed5a2a134f53276fc5762672114e7d3 Mon Sep 17 00:00:00 2001 From: Stephan Wurm <121798939+swaeberle@users.noreply.github.com> Date: Wed, 5 Jul 2023 16:09:28 +0200 Subject: [PATCH] Allow single label hostname in format string When validating hostname format strings with module fqdn, only FQDNs were accepted, as the minimum label length of the FQDN class is 2. Therefore, single label hostnames like "localhost" were rejected. Fixed this by validating with a minimum label length of 1. Signed-off-by: Stephan Wurm --- jsonschema/_format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsonschema/_format.py b/jsonschema/_format.py index f9f82bbe..25d4caa7 100644 --- a/jsonschema/_format.py +++ b/jsonschema/_format.py @@ -274,7 +274,7 @@ def is_ipv6(instance: object) -> bool: def is_host_name(instance: object) -> bool: if not isinstance(instance, str): return True - return FQDN(instance).is_valid + return FQDN(instance, min_labels=1).is_valid with suppress(ImportError):