fix: prevent remote from messing with constructor names (#22820)
This commit is contained in:
parent
746266bd93
commit
b327478cf0
2 changed files with 17 additions and 4 deletions
|
@ -22,6 +22,8 @@ process.on('exit', () => {
|
|||
ipcRendererInternal.send(command, contextId);
|
||||
});
|
||||
|
||||
const IS_REMOTE_PROXY = Symbol('is-remote-proxy');
|
||||
|
||||
// Convert the arguments object into an array of meta data.
|
||||
function wrapArgs (args, visited = new Set()) {
|
||||
const valueToMeta = (value) => {
|
||||
|
@ -188,6 +190,7 @@ function proxyFunctionProperties (remoteMemberFunction, metaId, name) {
|
|||
return true;
|
||||
},
|
||||
get: (target, property, receiver) => {
|
||||
if (property === IS_REMOTE_PROXY) return true;
|
||||
if (!Object.prototype.hasOwnProperty.call(target, property)) loadRemoteProperties();
|
||||
const value = target[property];
|
||||
if (property === 'toString' && typeof value === 'function') {
|
||||
|
@ -247,7 +250,9 @@ function metaToValue (meta) {
|
|||
|
||||
setObjectMembers(ret, ret, meta.id, meta.members);
|
||||
setObjectPrototype(ret, ret, meta.id, meta.proto);
|
||||
Object.defineProperty(ret.constructor, 'name', { value: meta.name });
|
||||
if (ret.constructor && ret.constructor[IS_REMOTE_PROXY]) {
|
||||
Object.defineProperty(ret.constructor, 'name', { value: meta.name });
|
||||
}
|
||||
|
||||
// Track delegate obj's lifetime & tell browser to clean up when object is GCed.
|
||||
v8Util.setRemoteObjectFreer(ret, contextId, meta.id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue