Skip to content

Commit d123050

Browse files
committed
chore: apply remaining changes
1 parent e1bc180 commit d123050

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎lib/child_process.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const {
3838
ObjectPrototypeHasOwnProperty,
3939
PromiseWithResolvers,
4040
RegExpPrototypeExec,
41+
RegExpPrototypeSymbolReplace,
4142
SafeSet,
4243
StringPrototypeIncludes,
4344
StringPrototypeIndexOf,
@@ -603,7 +604,10 @@ function copyPermissionModelFlagsToEnv(env, key, args) {
603604
env[key] = `${env[key] ? env[key] + ' ' : ''}${flag}`;
604605
} else if (ArrayIsArray(value)) {
605606
for (const item of value) {
606-
env[key] = `${env[key] ? env[key] + ' ' : ''}${flag}=${item}`;
607+
// Values may contain spaces or quotes (e.g. the implicitly allowed
608+
// entry point), so quote them as NODE_OPTIONS expects.
609+
const quoted = RegExpPrototypeSymbolReplace(/["\\]/g, item, '\\$&');
610+
env[key] = `${env[key] ? env[key] + ' ' : ''}"${flag}=${quoted}"`;
607611
}
608612
}
609613
}

‎test/fixtures/permission/config-child-inherit.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"allow-child-process": true,
55
"allow-worker": true,
66
"allow-fs-read": [
7-
"*"
7+
"*",
8+
"/nonexistent/dir with \"quotes\" and \\backslash"
89
]
910
}
1011
}

0 commit comments

Comments
 (0)