From cffb4983730fdce034b921876559c1d9d7fbaed6 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 15 Apr 2019 01:50:58 +0200 Subject: [PATCH] worker: simplify filename checks Replace a couple of checks with a single regular expression. --- lib/internal/worker.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/internal/worker.js b/lib/internal/worker.js index 53e3c7668c31a0..796d1713dd510a 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -68,11 +68,7 @@ class Worker extends EventEmitter { options.execArgv); } if (!options.eval) { - if (!path.isAbsolute(filename) && - !filename.startsWith('./') && - !filename.startsWith('../') && - !filename.startsWith('.' + path.sep) && - !filename.startsWith('..' + path.sep)) { + if (!path.isAbsolute(filename) && !/^\.\.?[\\/]/.test(filename)) { throw new ERR_WORKER_PATH(filename); } filename = path.resolve(filename);