From b050de1645ebcb586a4104ba96fa3e0de3602f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Alby?= Date: Mon, 7 Oct 2019 15:30:42 +0700 Subject: [PATCH] Merge pull request #2208 from overleaf/ta-handle-express-uri-error Handle Express URIError GitOrigin-RevId: 6f22110971c8bdb1a7a2e5ba7043c37348b9092e --- .../web/app/src/Features/Errors/ErrorController.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/web/app/src/Features/Errors/ErrorController.js b/services/web/app/src/Features/Errors/ErrorController.js index f481bd17b4..1083effe6c 100644 --- a/services/web/app/src/Features/Errors/ErrorController.js +++ b/services/web/app/src/Features/Errors/ErrorController.js @@ -30,6 +30,13 @@ module.exports = ErrorController = { } else if (error instanceof Errors.NotFoundError) { logger.warn({ err: error, url: req.url }, 'not found error') ErrorController.notFound(req, res) + } else if ( + error instanceof URIError && + error.message.match(/^Failed to decode param/) + ) { + logger.warn({ err: error, url: req.url }, 'Express URIError') + res.status(400) + res.render('general/500', { title: 'Invalid Error' }) } else if (error instanceof Errors.ForbiddenError) { logger.error({ err: error }, 'forbidden error') ErrorController.forbidden(req, res) @@ -64,6 +71,12 @@ module.exports = ErrorController = { if (error instanceof Errors.NotFoundError) { logger.warn({ err: error, url: req.url }, 'not found error') res.sendStatus(404) + } else if ( + error instanceof URIError && + error.message.match(/^Failed to decode param/) + ) { + logger.warn({ err: error, url: req.url }, 'Express URIError') + res.sendStatus(400) } else { logger.error( { err: error, url: req.url, method: req.method },