mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-12-02 05:04:13 +01:00
Avoid passing caught exception text directly to res.send on upload errors
This commit is contained in:
1 parent
47bdd3d2dc
commit
de5f80e0ff
2 files changed
+10
-4
No files matched your search
@@ -63,8 +63,10 @@ class MiscController {
|
||||
if (error instanceof uploadPath.UploadError) {
|
||||
Logger.warn(`[MiscController] User "${req.user.username}" upload failed (${error.statusCode}): ${error.message}`)
|
||||
if (error.body) return res.status(error.statusCode).json(error.body)
|
||||
// Send only a known plain-text literal rather than arbitrary exception text.
|
||||
const message = uploadPath.PLAIN_TEXT_UPLOAD_ERRORS.find((known) => known === error.message)
|
||||
res.type('text/plain')
|
||||
return res.status(error.statusCode).send(error.message)
|
||||
return message ? res.status(error.statusCode).send(message) : res.sendStatus(error.statusCode)
|
||||
}
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user