Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DI] allow "." and "-" in env processor lines #35029

Merged
merged 1 commit into from Dec 19, 2019

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #34864
License MIT
Doc PR -

As explained in the linked issue, this is especially usefull with the key processor.

throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name));
}
if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) {
throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name));
}

$uniqueName = md5($name.'_'.self::$counter++);
$placeholder = sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(), str_replace(':', '_', $env), $uniqueName);
$placeholder = sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(), strtr($env, ':-.', '___'), $uniqueName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replacing the 3 chars with the same replacement will be an issue: we can have multiple env lines producing the same placeholder, which will go wrong when reverting them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an md5 on the line before that will prevent any collisions from happening.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah indeed. I missed that.

@fabpot
Copy link
Member

fabpot commented Dec 19, 2019

Thank you @nicolas-grekas.

fabpot added a commit that referenced this pull request Dec 19, 2019
…-grekas)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[DI] allow "." and "-" in env processor lines

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #34864
| License       | MIT
| Doc PR        | -

As explained in the linked issue, this is especially usefull with the `key` processor.

Commits
-------

231c505 [DI] allow "." and "-" in env processor lines
@fabpot fabpot merged commit 231c505 into symfony:master Dec 19, 2019
@nicolas-grekas nicolas-grekas deleted the di-extra-chr branch January 4, 2020 14:50
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 2020
nicolas-grekas added a commit that referenced this pull request Oct 13, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[DI] fix dumping env vars

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Forgotten in #35029
For 4.4 to reduce merge conflicts (it doesn't allow the new chars in 4.4 anyway, #35029 is still needed)

Commits
-------

746a8d1 [DI] fix dumping env vars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dependency Injection] - Invalid env(p-redis-osb) name: only "word" characters are allowed.
5 participants