mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
fix: use CreateDataProperty when copying objects across contextBridge (#51085)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Sam Attard <sattard@anthropic.com>
This commit is contained in:
@@ -725,7 +725,18 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
|
||||
{
|
||||
v8::Context::Scope inner_destination_context_scope(
|
||||
destination_context);
|
||||
proxy.Set(key, passed_value.ToLocalChecked());
|
||||
// Use CreateDataProperty (not Set) so that a key named "__proto__"
|
||||
// becomes an own data property instead of invoking the inherited
|
||||
// Object.prototype.__proto__ setter and mutating the prototype.
|
||||
v8::Local<v8::Value> proxied_value = passed_value.ToLocalChecked();
|
||||
if (key->IsName()) {
|
||||
std::ignore = proxy.GetHandle()->CreateDataProperty(
|
||||
destination_context, key.As<v8::Name>(), proxied_value);
|
||||
} else {
|
||||
std::ignore = proxy.GetHandle()->CreateDataProperty(
|
||||
destination_context, key.As<v8::Uint32>()->Value(),
|
||||
proxied_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user