Protocol Filter: Catch and return 'invalid url' on all errors
This commit is contained in:
parent
b54c6f257d
commit
6a1b6f2e44
|
@ -84,18 +84,7 @@ function _createFileHandler({
|
|||
|
||||
try {
|
||||
targetPath = _urlToPath(request.url, { isWindows });
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err && typeof err.message === 'string'
|
||||
? err.message
|
||||
: 'no error message';
|
||||
console.log(
|
||||
`Warning: denying request because of an error: ${errorMessage}`
|
||||
);
|
||||
|
||||
callback({ error: -300 });
|
||||
return;
|
||||
}
|
||||
// normalize() is primarily useful here for switching / to \ on windows
|
||||
const target = normalize(targetPath);
|
||||
// here we attempt to follow symlinks to the ultimate final path, reflective of what
|
||||
|
@ -126,6 +115,17 @@ function _createFileHandler({
|
|||
`Warning: denying request to path '${realPath}' (allowedRoots: '${allowedRoots}')`
|
||||
);
|
||||
callback({ error: -10 });
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err && typeof err.message === 'string'
|
||||
? err.message
|
||||
: 'no error message';
|
||||
console.log(
|
||||
`Warning: denying request because of an error: ${errorMessage}`
|
||||
);
|
||||
|
||||
callback({ error: -300 });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue