Skip to content

[DependencyInjection] YamlDumper doesn’t quote resolved env placeholders #60573

Closed
@MatTheCat

Description

@MatTheCat

Symfony version(s) affected

≥ 3.2

Description

When dumping a compiled container, env placeholders like env_f10f3d959fafc55a_FOO_9a1a890d5dc971890ff9dac294110492 don’t need to be quoted, but since resolveEnvPlaceholders is called on the resulting dump, those will be replaced without being quoted, thus making the Parser crash.

How to reproduce

$container = new ContainerBuilder();
$container->setParameter('foo', '%env(FOO)%');
$container->compile();

(new Parser())->parse((new YamlDumper($container))->dump()));

Symfony\Component\Yaml\Exception\ParseException: The reserved indicator "%" cannot start a plain scalar; you need to quote the scalar at line 2 (near "foo: %env(FOO)%").

Possible Solution

resolveEnvPlaceholders should be called for each string able to contain such placeholders rather than the entire dump.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions