Improve trusted-prevent-dom-bypass scriptlet

This commit is contained in:
Raymond Hill 2025-03-25 12:12:00 -04:00
parent 5e9737d38e
commit 68a256bdde
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -2686,7 +2686,16 @@ function trustedPreventDomBypass(
}
}
if ( targetProp !== '' ) {
elem.contentWindow[targetProp] = self[targetProp];
let me = self, it = elem.contentWindow;
let chain = targetProp;
for (;;) {
const pos = chain.indexOf('.');
if ( pos === -1 ) { break; }
const prop = chain.slice(0, pos)
me = me[prop]; it = it[prop];
chain = chain.slice(pos+1);
}
it[chain] = me[chain];
} else {
Object.defineProperty(elem, 'contentWindow', { value: self });
}