-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
util.parseEnv creates keys from invalid, newline-separated lines #56775
Comments
How does dotenv handle this? I think this is expected behavior. |
IMO node should output: {
foo: true,
bar: true,
baz: 'whatever',
} and dotenv do that const dotenv = require('dotenv');
const input = ` foo
bar
baz=whatever
`;
const output = dotenv.parse(input);
console.log(output); // => { baz: 'whatever' }
|
I think dotenv's behavior is more correct. But dotenv also supports multiline arguments. I think we shouldn't accept newline characters when parsing key's |
I never heard about that. Could you give me an example. you mean that ? |
Line 72 of https://github.com/nodejs/node/blob/main/test/parallel/test-dotenv.js |
+1 for Dotenv behavior. We should use same fixtures Can I fix this issue ? i know the answers is yes But I mean is it an easy task. |
Yes, node_dotenv.cc |
I think multiline arguments are more common than multiline keys |
I'll go with whatever the consensus is, but IMHO |
Since one doesn't exist, I thought i would get a spec started for I'm open to any level of contributions if anyone is interested. |
Version
v23.6.1
Platform
Subsystem
No response
What steps will reproduce the bug?
Do:
Then create a string with some invalid lines:
And parse it:
How often does it reproduce? Is there a required condition?
Tested on node versions v21x-v23.6.1
What is the expected behavior? Why is that the expected behavior?
Expected behavior, IMHO, would be throw an invalid syntax error.
What do you see instead?
Invalid output.
Additional information
No response
The text was updated successfully, but these errors were encountered: