-
Notifications
You must be signed in to change notification settings - Fork 902
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
Fix bug where dotenv file using quotes greedily consumes values. #3703
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
- Fixes bug where functions packaged as ES module failed to load on Windows. (#3692) | ||
- Fixes bug parsing dotenv files with multiple quoted values (#3703) | ||
- Tracks use of runtime config and environment variables on function deploys. (#3704) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,19 +40,19 @@ const RESERVED_KEYS = [ | |
// https://github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb | ||
// prettier-ignore | ||
const LINE_RE = new RegExp( | ||
"^" + // begin line | ||
"\\s*" + // leading whitespaces | ||
"(\\w+)" + // key | ||
"\\s*=\\s*" + // separator (=) | ||
"(" + // begin optional value | ||
"\\s*'(?:\\'|[^'])*'|" + // single quoted or | ||
'\\s*"(?:\\"|[^"])*"|' + // double quoted or | ||
"[^\\#\\r\\n]+" + // unquoted | ||
")?" + // end optional value | ||
"\\s*" + // trailing whitespaces | ||
"(?:#[^\\n]*)?" + // optional comment | ||
"$", // end line | ||
"gms" // flags: global, multiline, dotall | ||
"^" + // begin line | ||
"\\s*" + // leading whitespaces | ||
"(\\w+)" + // key | ||
"\\s*=\\s*" + // separator (=) | ||
"(" + // begin optional value | ||
"\\s*'(?:\\\\'|[^'])*'|" + // single quoted or | ||
'\\s*"(?:\\\\"|[^"])*"|' + // double quoted or | ||
"[^\\#\\r\\n]+" + // unquoted | ||
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. I thought we decided that the 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. Yes. It looks like regex implementation ignores wrongly escaped characters, so I got lucky here:
|
||
")?" + // end optional value | ||
"\\s*" + // trailing whitespaces | ||
"(?:#[^\\n]*)?" + // optional comment | ||
"$", // end line | ||
"gms" // flags: global, multiline, dotall | ||
); | ||
|
||
interface ParseResult { | ||
|
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.
value is no longer optional
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 think it still is? The relevant test case still passes:
https://github.com/firebase/firebase-tools/blob/master/src/test/functions/env.spec.ts#L83
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 thought the backend didn't support it?
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.
Oh that's what I thought too but just checked deploying empty env var and confirmed that it's a valid value.