Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 53eae0d

Browse filesBrowse files
bzozaddaleax
authored andcommitted
process: correctly parse Unicode in NODE_OPTIONS
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed correctly. Fixes: #34399 PR-URL: #34476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
1 parent 9d52480 commit 53eae0d
Copy full SHA for 53eae0d

File tree

Expand file treeCollapse file tree

2 files changed

+40
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+40
-2
lines changed
Open diff view settings
Collapse file

‎src/node_credentials.cc‎

Copy file name to clipboardExpand all lines: src/node_credentials.cc
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,20 @@ bool SafeGetenv(const char* key, std::string* text, Environment* env) {
5858

5959
{
6060
Mutex::ScopedLock lock(per_process::env_var_mutex);
61-
if (const char* value = getenv(key)) {
62-
*text = value;
61+
62+
size_t init_sz = 256;
63+
MaybeStackBuffer<char, 256> val;
64+
int ret = uv_os_getenv(key, *val, &init_sz);
65+
66+
if (ret == UV_ENOBUFS) {
67+
// Buffer is not large enough, reallocate to the updated init_sz
68+
// and fetch env value again.
69+
val.AllocateSufficientStorage(init_sz);
70+
ret = uv_os_getenv(key, *val, &init_sz);
71+
}
72+
73+
if (ret >= 0) { // Env key value fetch success.
74+
*text = *val;
6375
return true;
6476
}
6577
}
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
// Flags: --expose-internals
3+
require('../common');
4+
const { getOptionValue } = require('internal/options');
5+
const assert = require('assert');
6+
const cp = require('child_process');
7+
8+
const expected_redirect_value = 'foó';
9+
10+
if (process.argv.length === 2) {
11+
const NODE_OPTIONS = `--redirect-warnings=${expected_redirect_value}`;
12+
const result = cp.spawnSync(process.argv0,
13+
['--expose-internals', __filename, 'test'],
14+
{
15+
env: {
16+
...process.env,
17+
NODE_OPTIONS
18+
},
19+
stdio: 'inherit'
20+
});
21+
assert.strictEqual(result.status, 0);
22+
} else {
23+
const redirect_value = getOptionValue('--redirect-warnings');
24+
console.log(`--redirect-warings=${redirect_value}`);
25+
assert.strictEqual(redirect_value, expected_redirect_value);
26+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.