★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/5450e48f69Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files
worker: simplify filename checks
Replace a couple of checks with a single regular expression.

PR-URL: #27233
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
  • Loading branch information
BridgeAR authored and ZYSzys committed Apr 17, 2019
1 parent c61c722 commit 5450e48f6931d7960da88a96ddaab9f19dd4c788
Showing with 1 addition and 5 deletions.
  1. +1 −5 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);

0 comments on commit 5450e48

Please sign in to comment.