File protocol filter: log when non-absolute path is rejected

This commit is contained in:
Scott Nonnenberg 2018-05-30 18:11:59 -07:00
parent 71d873ccfe
commit 7c3325f55e

View file

@ -26,11 +26,12 @@ function _createFileHandler({ userDataPath, installPath, isWindows }) {
const target = path.normalize(_urlToPath(request.url, { isWindows }));
if (!path.isAbsolute(target)) {
console.log(`Warning: denying request to non-absolute path '${target}'`);
return callback();
}
if (!target.startsWith(userDataPath) && !target.startsWith(installPath)) {
console.log(`Warning: denying request to ${target}`);
console.log(`Warning: denying request to path '${target}'`);
return callback();
}