Revert "feat: only allow bundled preload scripts (#17308)" (#18091)

This reverts commit 8cf15cc931.
This commit is contained in:
Milan Burda 2019-06-20 01:39:12 +02:00 committed by Cheng Zhao
parent 257fd2c0df
commit 4575a4aae3
9 changed files with 0 additions and 76 deletions

View file

@ -1,5 +1,4 @@
import { EventEmitter } from 'events'
import * as fs from 'fs'
import * as path from 'path'
const Module = require('module')
@ -191,22 +190,10 @@ if (nodeIntegration) {
}
const errorUtils = require('@electron/internal/common/error-utils')
const { isParentDir } = require('@electron/internal/common/path-utils')
let absoluteAppPath: string
const getAppPath = function () {
if (absoluteAppPath === undefined) {
absoluteAppPath = fs.realpathSync(appPath!)
}
return absoluteAppPath
}
// Load the preload scripts.
for (const preloadScript of preloadScripts) {
try {
if (!isParentDir(getAppPath(), fs.realpathSync(preloadScript))) {
throw new Error('Preload scripts outside of app path are not allowed')
}
Module._load(preloadScript)
} catch (error) {
console.error(`Unable to load preload script: ${preloadScript}`)