-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Unicode characters are not properly parsed from NODE_OPTIONS on Windows #34399
Comments
cc @nodejs/platform-windows |
Switching to diff --git a/src/node_credentials.cc b/src/node_credentials.cc
index d552a50172..e77d0378b2 100644
--- a/src/node_credentials.cc
+++ b/src/node_credentials.cc
@@ -57,9 +57,23 @@ bool SafeGetenv(const char* key, std::string* text, Environment* env) {
}
{
- Mutex::ScopedLock lock(per_process::env_var_mutex);
- if (const char* value = getenv(key)) {
- *text = value;
+ MaybeStackBuffer<char, 256> value;
+ size_t size = 256; // TODO(bnoordhuis) DRY, re-use kStackStorageSize here.
+ int rc;
+
+ {
+ Mutex::ScopedLock lock(per_process::env_var_mutex);
+ rc = uv_os_getenv(key, *value, &size);
+ }
+
+ if (rc == UV_ENOBUFS) {
+ value.AllocateSufficientStorage(size);
+ Mutex::ScopedLock lock(per_process::env_var_mutex);
+ rc = uv_os_getenv(key, *value, &size);
+ }
+
+ if (rc >= 0) {
+ *text = *value;
return true;
}
} |
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed correctly. Fixes: nodejs#34399
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed correctly. Fixes: #34399 PR-URL: #34476 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed correctly. Fixes: #34399 PR-URL: #34476 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed correctly. Fixes: #34399 PR-URL: #34476 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed correctly. Fixes: #34399 PR-URL: #34476 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
I stumbled on this while opening an issue (facebook/create-react-app#13117) and digging to make sure I understood everything. If you compare the windows impl with other OSs, I can see the other impls use classic This probably makes little practical difference. But locks are locks, I bet someone, somewhere, would see a benefit from eliminating it. |
What steps will reproduce the bug?
foó.js
containingconsole.log("in foó");
, and anbar.js
withconsole.log("in bar");
index.js
containingindex.js
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior?
Output like:
What do you see instead?
Additional information
shell: true/false
inspawn()
console.log(process.env.HELLO)
in the above example prints out fine\\\\xF3
, but it doesn't look like Node tries to parse these from the string.References: microsoft/vscode-js-debug#563
The text was updated successfully, but these errors were encountered: