diff --git a/app/Support/ValidationPatterns.php b/app/Support/ValidationPatterns.php index 54397d4f1..7e3974dd7 100644 --- a/app/Support/ValidationPatterns.php +++ b/app/Support/ValidationPatterns.php @@ -109,7 +109,7 @@ class ValidationPatterns * path components. A trailing @sha256 marker is accepted for existing * digest-based dockerimage records that store the digest hash separately. */ - public const DOCKER_IMAGE_NAME_PATTERN = '/\A(?=.{1,255}\z)(?:(?:[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::[0-9]+)?\/)?[a-z0-9]+(?:(?:[._-]|__)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:[._-]|__)[a-z0-9]+)*)*)(?:@sha256)?\z/'; + public const DOCKER_IMAGE_NAME_PATTERN = '/\A(?=.{1,255}\z)(?:(?:[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::[0-9]+)?\/)?[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*)*)(?:@sha256)?\z/'; /** * Pattern for Docker image tags. diff --git a/tests/Unit/DockerImageReferenceValidationTest.php b/tests/Unit/DockerImageReferenceValidationTest.php index d6bf2ebd5..5ee85f24b 100644 --- a/tests/Unit/DockerImageReferenceValidationTest.php +++ b/tests/Unit/DockerImageReferenceValidationTest.php @@ -13,6 +13,7 @@ 'single component' => 'nginx', 'namespace image' => 'library/nginx', 'ghcr image' => 'ghcr.io/coollabsio/coolify', + 'repository component with repeated hyphens' => 'ghcr.io/acme/my--service', 'registry with port' => 'registry.example.com:5000/team/app', 'digest marker used by existing dockerimage records' => 'nginx@sha256', ]);