chore: disable the remote module in devtools / chrome extension background scripts (#16866)
* cache isRemoteModuleEnabled * chore: disable the remote module in devtools / chrome extension background scripts
This commit is contained in:
parent
a3cdf46fb6
commit
d8ba1278d1
6 changed files with 20 additions and 17 deletions
|
@ -264,10 +264,20 @@ const callFunction = function (event, contextId, func, caller, args) {
|
|||
}
|
||||
}
|
||||
|
||||
const isRemoteModuleEnabledCache = new WeakMap()
|
||||
|
||||
const isRemoteModuleEnabled = function (contents) {
|
||||
if (!isRemoteModuleEnabledCache.has(contents)) {
|
||||
isRemoteModuleEnabledCache.set(contents, contents._isRemoteModuleEnabled())
|
||||
}
|
||||
|
||||
return isRemoteModuleEnabledCache.get(contents)
|
||||
}
|
||||
|
||||
const handleRemoteCommand = function (channel, handler) {
|
||||
ipcMainInternal.on(channel, (event, contextId, ...args) => {
|
||||
let returnValue
|
||||
if (!event.sender._isRemoteModuleEnabled()) {
|
||||
if (!isRemoteModuleEnabled(event.sender)) {
|
||||
event.returnValue = null
|
||||
return
|
||||
}
|
||||
|
@ -506,7 +516,7 @@ ipcMainInternal.on('ELECTRON_BROWSER_SANDBOX_LOAD', function (event) {
|
|||
|
||||
event.returnValue = {
|
||||
preloadScripts: preloadPaths.map(path => getPreloadScript(path)),
|
||||
isRemoteModuleEnabled: event.sender._isRemoteModuleEnabled(),
|
||||
isRemoteModuleEnabled: isRemoteModuleEnabled(event.sender),
|
||||
isWebViewTagEnabled: guestViewManager.isWebViewTagEnabled(event.sender),
|
||||
process: {
|
||||
arch: process.arch,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue