mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(compose): strip UTF-8 BOM before parsing Docker Compose YAML (#12223)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(TestCase::class);
|
||||
|
||||
it('parses a Docker Compose file that starts with a UTF-8 byte order mark', function () {
|
||||
$compose = "\xEF\xBB\xBFservices:\n web:\n image: nginx:alpine\n";
|
||||
|
||||
expect(parseDockerComposeYaml($compose))->toBe([
|
||||
'services' => [
|
||||
'web' => ['image' => 'nginx:alpine'],
|
||||
],
|
||||
]);
|
||||
|
||||
validateDockerComposeForInjection($compose);
|
||||
});
|
||||
Reference in New Issue
Block a user