diff --git a/bootstrap/helpers/parsers.php b/bootstrap/helpers/parsers.php index 21f0d7326d..66330d9d09 100644 --- a/bootstrap/helpers/parsers.php +++ b/bootstrap/helpers/parsers.php @@ -26,6 +26,9 @@ use Symfony\Component\Yaml\Yaml; */ function parseDockerComposeYaml(string $compose): mixed { + // Editors on Windows can save files with a UTF-8 BOM, which Symfony YAML keeps in the first key. + $compose = preg_replace('/^\xEF\xBB\xBF/', '', $compose); + return Yaml::parse($compose, maxAliasesForCollections: Application::MAX_DOCKER_COMPOSE_COLLECTION_ALIASES); } diff --git a/tests/Unit/DockerComposeByteOrderMarkTest.php b/tests/Unit/DockerComposeByteOrderMarkTest.php new file mode 100644 index 0000000000..50f94b9812 --- /dev/null +++ b/tests/Unit/DockerComposeByteOrderMarkTest.php @@ -0,0 +1,17 @@ +toBe([ + 'services' => [ + 'web' => ['image' => 'nginx:alpine'], + ], + ]); + + validateDockerComposeForInjection($compose); +});