From 3d546e4bfe491d84b058a4a50a48573977bc87c4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Feb 2026 21:46:31 +0000 Subject: [PATCH 1/2] Fix hostname label length validation to enforce RFC 1035 limits Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com> --- src/JsonSchema/Constraints/FormatConstraint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonSchema/Constraints/FormatConstraint.php b/src/JsonSchema/Constraints/FormatConstraint.php index 9ed4df9d..f888ebef 100644 --- a/src/JsonSchema/Constraints/FormatConstraint.php +++ b/src/JsonSchema/Constraints/FormatConstraint.php @@ -210,7 +210,7 @@ protected function validateHostname($host) return true; } - $hostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/i'; + $hostnameRegex = '/^(?!-)(?!.*?[^A-Za-z0-9\-\.])(?:(?!-)[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?\.)*(?!-)[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?$/'; return preg_match($hostnameRegex, $host); } From 0ef4138556144b39b3ec4637e60f1cf5a2075a51 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Feb 2026 22:07:05 +0000 Subject: [PATCH 2/2] Add RFC 1035 comment explaining hostname label length limit Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com> --- src/JsonSchema/Constraints/FormatConstraint.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/JsonSchema/Constraints/FormatConstraint.php b/src/JsonSchema/Constraints/FormatConstraint.php index f888ebef..c38488dd 100644 --- a/src/JsonSchema/Constraints/FormatConstraint.php +++ b/src/JsonSchema/Constraints/FormatConstraint.php @@ -210,6 +210,7 @@ protected function validateHostname($host) return true; } + // RFC 1035: labels are max 63 chars (1 start + 0-61 middle + 1 end) $hostnameRegex = '/^(?!-)(?!.*?[^A-Za-z0-9\-\.])(?:(?!-)[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?\.)*(?!-)[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?$/'; return preg_match($hostnameRegex, $host);