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
Fixing a bug where empty variables in .env files were read as multi-line values (#3934) #3951
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74d9460
Fixing a bug where empty variables in .env files were read as multi-l…
joehan 7a27451
changelog
joehan 4da74de
take 2
joehan 7cb6dee
Merge branch 'master' into jh-fix-multiline
joehan 13a7c8d
formats
joehan bafc3d8
adding another test case
joehan 1062255
Merge branch 'master' into jh-fix-multiline
joehan File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
- Fixes issue when installing a Firebase Extension where secrets would be created before validation. | ||
- Fixes issue with filtering on a specific storage bucket using functions in the emulator (#3893) | ||
- Fixes check in Cloud Functions for Firebase initialization to check for API enablement before trying to enable them. (#2574) | ||
- No longer tries to clean up function build images from Artifact Registry when Artifact Registry is not enabled (#3943) | ||
- No longer tries to clean up function build images from Artifact Registry when Artifact Registry is not enabled. (#3943) | ||
- Fixes issue where empty variables in .env files would instead read as multi-line values. (#3934) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,26 +135,33 @@ BAR=bar | |
want: { FOO: "foo" }, | ||
}, | ||
{ | ||
description: "should ignore comments", | ||
description: "should handle empty values", | ||
input: ` | ||
FOO=foo # comment | ||
# line comment 1 | ||
# line comment 2 | ||
BAR=bar # another comment | ||
FOO= | ||
BAR= "blah" | ||
`, | ||
want: { FOO: "foo", BAR: "bar" }, | ||
}, | ||
{ | ||
description: "should ignore empty lines", | ||
input: ` | ||
FOO=foo | ||
|
||
|
||
BAR=bar | ||
|
||
`, | ||
want: { FOO: "foo", BAR: "bar" }, | ||
want: { FOO: "", BAR: "blah" }, | ||
}, | ||
// { | ||
// description: "should ignore comments", | ||
// input: ` | ||
// FOO=foo # comment | ||
// # line comment 1 | ||
// # line comment 2 | ||
// BAR=bar # another comment | ||
// `, | ||
// want: { FOO: "foo", BAR: "bar" }, | ||
// }, | ||
// { | ||
// description: "should ignore empty lines", | ||
// input: ` | ||
// FOO=foo | ||
|
||
// BAR=bar | ||
|
||
// `, | ||
// want: { FOO: "foo", BAR: "bar" }, | ||
// }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to uncomment this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤦 Forgot to save the file before commiting |
||
]; | ||
|
||
tests.forEach(({ description, input, want }) => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
q: Did we need
=
?IIUC, we are making something like
from being a valid entry (
{FOO: "bar=a"}
) to an invalid one.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.
Hmmm, its a bit of a weird case - i guess what we really want to do is allow =, but not after a line break?
So something like
There may be other regex tricks that could solve this as well - maybe replacing the
\\s
that. matches whitespace after the equals with something that doesn't match newlines?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.
Ahhhh, i just read your original code comments more closely, and realized we explicitly don't support multiline unquoted values. I think i know how to fix this, will play around a bit and make sure all the tests work.