-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
src: add support for escaping quotes with escape slash in --env-file
#50814
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -52,6 +52,8 @@ void Dotenv::SetEnvironment(node::Environment* env) { | |
| auto existing = env->env_vars()->Get(key.data()); | ||
|
|
||
| if (existing.IsNothing()) { | ||
| // Remove all '\' characters from value | ||
| value.erase(std::remove(value.begin(), value.end(), '\\'), value.end()); | ||
|
Contributor
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. Should this be moved to
Contributor
Author
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. Thank you for your comment.
Contributor
Author
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. Sorry, I checked further and found what you said was correct. I applied it. |
||
| env->env_vars()->Set( | ||
| isolate, | ||
| v8::String::NewFromUtf8( | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,7 @@ EQUAL_SIGNS=equals== | |||||
| RETAIN_INNER_QUOTES={"foo": "bar"} | ||||||
| RETAIN_INNER_QUOTES_AS_STRING='{"foo": "bar"}' | ||||||
| RETAIN_INNER_QUOTES_AS_BACKTICKS=`{"foo": "bar's"}` | ||||||
| RETAIN_INNER_QUOTES_AS_ESCAPE_SLASH=`{\"foo\": \"bar\"}` | ||||||
|
Contributor
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. Maybe add e.g.
Member
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. What's the default behavior of dotenv?
Contributor
Author
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. There was a problem with the current implementation, so I modified it and added the test you commented on.
Contributor
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. @pluris Thanks for the quick fix! I think there is still an issue. I would expect the test to read: instead of the current That is, escaping a backslash should result in just one backslash... This is also what dotenv does, @anonrig.
Member
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.
Suggested change
|
||||||
| TRIM_SPACE_FROM_UNQUOTED= some spaced out string | ||||||
| EMAIL=therealnerdybeast@example.tld | ||||||
| SPACED_KEY = parsed | ||||||
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.
What about escaping backslashes?
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 received comments and changed the implementation to apply only to
\".