worker: simplify filename checks
Replace a couple of checks with a single regular expression. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
c61c722c8c
commit
5450e48f69
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user