-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: node crashes due to multiline environment value #52266
Conversation
test/parallel/test-dotenv.js
Outdated
@@ -76,7 +76,7 @@ assert.strictEqual(process.env.EDGE_CASE_INLINE_COMMENTS, 'VALUE1'); | |||
assert.strictEqual(process.env.MULTI_DOUBLE_QUOTED, 'THIS\nIS\nA\nMULTILINE\nSTRING'); | |||
assert.strictEqual(process.env.MULTI_SINGLE_QUOTED, 'THIS\nIS\nA\nMULTILINE\nSTRING'); | |||
assert.strictEqual(process.env.MULTI_BACKTICKED, 'THIS\nIS\nA\n"MULTILINE\'S"\nSTRING'); | |||
assert.strictEqual(process.env.MULTI_NOT_VALID_QUOTE, '"'); | |||
assert.strictEqual(process.env.MULTI_NOT_VALID_QUOTE, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this cover all the added code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MULTI_NOT_VALID_QUOTE
test makes sure that if there's a line starting with a double quote that doesn't close, we still count it as one single value.
MULTI_NOT_VALID_QUOTE="
IMO we should keep this test to make sure we handle these situations right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dotenv interprets this as a single quote "
too not an empty value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this preserves the previous code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must have done this wrong I will update it today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a failing test?
I wonder if it's normal to get fail afterwards 🤔 |
you can make sure it throws |
I wanted to switch to the code in the main branch and test here, but I got such a test error ➜ node git:(dev-52248) ✗ ./node test/parallel/test-dotenv.js --NODE_SKIP_FLAG_CHECK
node:assert:126
throw new AssertionError(obj);
^
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected
+ undefined
- 'basic'
at Object.<anonymous> (/Users/mert/Desktop/openSource/node/test/parallel/test-dotenv.js:8:8)
at Module._compile (node:internal/modules/cjs/loader:1421:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1499:10)
at Module.load (node:internal/modules/cjs/loader:1232:32)
at Module._load (node:internal/modules/cjs/loader:1048:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:187:14)
at node:internal/main/run_main_module:28:49 {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: undefined,
expected: 'basic',
operator: 'strictEqual'
}
Node.js v22.0.0-pre |
Dotenv::ParseContent includes some improvements to avoid crash problems when processing a multiline value
#52248