From d6c4fa88e05ffd7da6dc4a437609dc4aa4c59e66 Mon Sep 17 00:00:00 2001 From: Westfall Date: Wed, 18 Jul 2018 08:52:29 +0200 Subject: [PATCH] Added more diagnostic messages --- server.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 3287a02..781a125 100644 --- a/server.js +++ b/server.js @@ -22,6 +22,9 @@ app.use((req, res, next) => { maxAge: 1000 * 60 * 60 * 24 * 365, httpOnly: false }); + + } else if(req.url.substring(1).toLowerCase().indexOf("html") > 0){ + console.warn("Served html file not in white list: %s", req.url); } next(); // <-- important! @@ -50,13 +53,17 @@ app.post("/receive", (request, respond) => { const tiddlyFile = request.query.loc; if (!getWhiteListIndex(tiddlyFile)) { - throw new Error("Tried to save tiddler not in white list."); + const notInWhiteListMessage = "Tried to save tiddler not in white list."; + console.error(notInWhiteListMessage); + respond.status(500).send(notInWhiteListMessage); } const filePath = path.join(config.dropBoxFolder, tiddlyFile); if (!filePath || filePath.indexOf(".html") < 0) { - throw new Error("Failed to get tiddler file path."); + const failedToGetPathMessage = "Failed to get tiddler file path."; + console.error(failedToGetPathMessage); + respond.status(500).send(failedToGetPathMessage); } const fileTime = fs.statSync(filePath).mtime;