util.parseEnv creates keys from invalid, newline-separated lines #56775
Open
Description
Version
v23.6.1
Platform
Darwin Mac.lan1 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:11 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6020 arm64
Subsystem
No response
What steps will reproduce the bug?
Do:
import { parseEnv } from 'node:util';
Then create a string with some invalid lines:
foo
bar
baz=whatever
And parse it:
const input = ` foo
bar
baz=whatever
`;
const env = parseEnv(input);
console.log(env);
// Outputs => { 'foo\n\n\nbar\nbaz': 'whatever' }
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