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

--env-file parses commented out parts, when they contain quotation marks #51508

Closed
pano9000 opened this issue Jan 18, 2024 · 1 comment · Fixed by #51510
Closed

--env-file parses commented out parts, when they contain quotation marks #51508

pano9000 opened this issue Jan 18, 2024 · 1 comment · Fixed by #51510
Assignees
Labels
confirmed-bug Issues with confirmed bugs. dotenv Issues and PRs related to .env file parsing

Comments

@pano9000
Copy link

Version

v20.9.0

Platform

Microsoft Windows NT 10.0.22621.0 x64

Subsystem

No response

What steps will reproduce the bug?

when using a .env file with entries like the one below, where there is a commented out part, nodeJS will parse the whole line as value, instead of just the expected "VALUE1" part.

KEY="VALUE1" # or "VALUE2" or "VALUE3"

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

Only happens, if the commented out part contains quotation marks as well.
Comments without quotation marks are correctly ignored, e.g.

KEY="VALUE1" # or 'VALUE2' or 'VALUE3' will correctly only parse the VALUE1 part as value

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

process.env.KEY should have the value VALUE1 only, the rest of the line is a comment that should not be parsed

What do you see instead?

Currently it parsed the whole line instead, removing the first and last quotation mark:
PROD" # or "TEST" or "DEV

So it looks like the behaviour currently is to find the first and last quotation mark and treat everything in between as the value.

The same line, when parsed by dotenv does not give the same wrong result.

Additional information

No response

@marco-ippolito marco-ippolito added the confirmed-bug Issues with confirmed bugs. label Jan 18, 2024
@anonrig anonrig added the dotenv Issues and PRs related to .env file parsing label Jan 18, 2024
@IlyasShabi
Copy link
Contributor

This is also fixed in this PR #51289
cc: @anonrig @marco-ippolito

nodejs-github-bot pushed a commit that referenced this issue Jan 20, 2024
PR-URL: #51510
Fixes: #51508
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
marco-ippolito added a commit to marco-ippolito/node that referenced this issue Feb 2, 2024
PR-URL: nodejs#51510
Fixes: nodejs#51508
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
targos pushed a commit that referenced this issue Feb 15, 2024
PR-URL: #51510
Fixes: #51508
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
marco-ippolito added a commit to marco-ippolito/node that referenced this issue Feb 19, 2024
PR-URL: nodejs#51510
Fixes: nodejs#51508
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
richardlau pushed a commit that referenced this issue Mar 25, 2024
PR-URL: #51510
Fixes: #51508
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
richardlau pushed a commit that referenced this issue Mar 25, 2024
PR-URL: #51510
Fixes: #51508
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. dotenv Issues and PRs related to .env file parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants