module: validate request in require.resolve.paths
PR-URL: https://github.com/nodejs/node/pull/18359 Fixes: https://github.com/nodejs/node/issues/18352 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Родитель
d4dd0665f5
Коммит
9fb91fe1d6
|
@ -27,6 +27,10 @@ function makeRequireFunction(mod) {
|
|||
require.resolve = resolve;
|
||||
|
||||
function paths(request) {
|
||||
if (typeof request !== 'string') {
|
||||
throw new errors.Error('ERR_INVALID_ARG_TYPE',
|
||||
'request', 'string', request);
|
||||
}
|
||||
return Module._resolveLookupPaths(request, mod, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,4 +47,11 @@ const re = /^The "request" argument must be of type string\. Received type \w+$/
|
|||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: re
|
||||
});
|
||||
|
||||
common.expectsError(
|
||||
() => { require.resolve.paths(value); },
|
||||
{
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: re
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче