mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 10:19:08 +00:00
Protocol Filter: Catch and return 'invalid url' on all errors
This commit is contained in:
@@ -84,18 +84,7 @@ function _createFileHandler({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
targetPath = _urlToPath(request.url, { isWindows });
|
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
|
// normalize() is primarily useful here for switching / to \ on windows
|
||||||
const target = normalize(targetPath);
|
const target = normalize(targetPath);
|
||||||
// here we attempt to follow symlinks to the ultimate final path, reflective of what
|
// 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}')`
|
`Warning: denying request to path '${realPath}' (allowedRoots: '${allowedRoots}')`
|
||||||
);
|
);
|
||||||
callback({ error: -10 });
|
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 });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user