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

@ -3,7 +3,6 @@
const electron = require('electron')
const { EventEmitter } = require('events')
const fs = require('fs')
const path = require('path')
const v8Util = process.electronBinding('v8_util')
const eventBinding = process.electronBinding('event')
@ -21,7 +20,6 @@ const guestViewManager = require('@electron/internal/browser/guest-view-manager'
const bufferUtils = require('@electron/internal/common/buffer-utils')
const errorUtils = require('@electron/internal/common/error-utils')
const clipboardUtils = require('@electron/internal/common/clipboard-utils')
const { isParentDir } = require('@electron/internal/common/path-utils')
const hasProp = {}.hasOwnProperty
@ -518,22 +516,11 @@ if (features.isDesktopCapturerEnabled()) {
})
}
let absoluteAppPath
const getAppPath = async function () {
if (absoluteAppPath === undefined) {
absoluteAppPath = await fs.promises.realpath(electron.app.getAppPath())
}
return absoluteAppPath
}
const getPreloadScript = async function (preloadPath) {
let preloadSrc = null
let preloadError = null
if (preloadPath) {
try {
if (!isParentDir(await getAppPath(), await fs.promises.realpath(preloadPath))) {
throw new Error('Preload scripts outside of app path are not allowed')
}
preloadSrc = (await fs.promises.readFile(preloadPath)).toString()
} catch (err) {
preloadError = errorUtils.serialize(err)