Fix DotEnv class turning export to empty string - #6625
Conversation
| $value = trim($value); | ||
|
|
||
| // Sanitize the name | ||
| $name = str_replace(['export', '\'', '"'], '', $name); |
There was a problem hiding this comment.
What is the purpose of deleting these strings?
There was a problem hiding this comment.
I'm not entirely sure, but I think this was meant to make 'foo' or "foo" to just foo
|
Is |
I think that was the intention. |
|
Okay. Since there was mention that the code comes mostly from It seems our DotEnv class is based on an old code. |
MGatner
left a comment
There was a problem hiding this comment.
Looks good, an edge case I would like to see covered.
|
Just saw your comment - should we use an actual package for this, either via Composer or unlined like we do with Kint? Seems like a high-risk security area to be based off old third-party code. |
Co-authored-by: MGatner <mgatner@icloud.com>
9637a81 to
eabdcbd
Compare
Well I'm in favor. Less maintenance burden on us. |
|
What security concern is in DotEnv? Config is a part that has slowed down considerably with CI4, and I don't want to see it get any heavier. |
|
It seems vlucas/phpdotenv support But for what? |
MGatner
left a comment
There was a problem hiding this comment.
I'm good with this fix for now. I do agree that Config has gotten rather bloated, but I think DotEnv is distinct enough (and necessary) that I would be in favor of some research at least about outsourcing it.
|
This is not related to this PR, but I've found this PHP extention:
|
| character.export.var=variable | ||
| export char.var=character | ||
| export char.exports=imports | ||
| fruit.export = "banana" |
There was a problem hiding this comment.
Before: $_ENV
'char.expo.foo' => string (12) "exported foo"
'character..var' => string (8) "variable"
' char.var' => string (9) "character"
' char.s' => string (7) "imports"
'fruit.' => string (6) "banana"
After: $_ENV
'char.expo.foo' => string (12) "exported foo"
'character.export.var' => string (8) "variable"
'char.var' => string (9) "character"
'char.exports' => string (7) "imports"
'fruit.export' => string (6) "banana"
There was a problem hiding this comment.
Node.js dotenv@16.0.3:
'char.expo.foo': 'exported foo',
'character.export.var': 'variable',
'char.var': 'character',
'char.exports': 'imports',
'fruit.export': 'banana'
It seems that export is handled the same way in Node dotenv as in this PR.
kenjis
left a comment
There was a problem hiding this comment.
As the bug fix, this has no problem.
|
Thanks for the reviews |
Description
Fixes #6621
I think the bug is on the incorrect sanitization of exported env variables with the syntax
export varname=value.Checklist: