From 54315b10e554b5715cc41588ecea19de2017ec39 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 19 Oct 2026 21:21:15 +0200 Subject: [PATCH] fix(compose): strip UTF-8 BOM before parsing Docker Compose YAML (#12223) --- bootstrap/helpers/parsers.php | 3 +++ tests/Unit/DockerComposeByteOrderMarkTest.php | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/Unit/DockerComposeByteOrderMarkTest.php 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); +});