Skip to content

util.parseEnv creates additional environment variables when equal sign is in value #57411

Open
@jablonski

Description

@jablonski

Version

v23.9.0

Platform

Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8122 arm64

Subsystem

util.parseEnv

What steps will reproduce the bug?

Just run the following code:

import { parseEnv } from "node:util";
console.log(parseEnv("A=B=C"));

How often does it reproduce? Is there a required condition?

Problem occurs on every run. This behaviour doesn't exist when using dotenv library.

What is the expected behavior? Why is that the expected behavior?

Output should be:

{ A: 'B=C' }

What do you see instead?

Output is:

{ A: 'B=C', B: 'C' }

Additional information

This behaviour might lead to undesirable side effects (even security might be affected).

Metadata

Metadata

Assignees

No one assigned

    Labels

    dotenvIssues and PRs related to .env file parsing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions