mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: only remove hijackable envs from foreign parent (#41099)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
This commit is contained in:
@@ -28,12 +28,6 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
|
||||
std::vector<v8::Local<v8::Value>>* arguments,
|
||||
node::Environment* optional_env);
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// Unset all environment variables that start with NODE_. Return false if there
|
||||
// is no node env at all.
|
||||
bool UnsetAllNodeEnvs();
|
||||
#endif
|
||||
|
||||
} // namespace electron::util
|
||||
|
||||
#endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright (c) 2023 Microsoft, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/node_util.h"
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
namespace electron::util {
|
||||
|
||||
bool UnsetAllNodeEnvs() {
|
||||
bool has_unset = false;
|
||||
for (NSString* env in NSProcessInfo.processInfo.environment) {
|
||||
if (![env hasPrefix:@"NODE_"])
|
||||
continue;
|
||||
const char* name = [[env componentsSeparatedByString:@"="][0] UTF8String];
|
||||
unsetenv(name);
|
||||
has_unset = true;
|
||||
}
|
||||
return has_unset;
|
||||
}
|
||||
|
||||
} // namespace electron::util
|
||||
Reference in New Issue
Block a user