diff options
author | David Mehren | 2021-02-19 11:57:11 +0100 |
---|---|---|
committer | GitHub | 2021-02-19 11:57:11 +0100 |
commit | 090d4178d96614ee55018a71336473c6d70935d2 (patch) | |
tree | 94e602f9816f0b6266090e85829ca4bdd0ae2023 /lib/web/note | |
parent | 50b8c73f4e788334e610fbb759f762fe251c0122 (diff) | |
parent | 7e597226ecb562ae7ca70a5aec9d37c42405aa54 (diff) |
Merge pull request #926 from hedgedoc/1.x/note-nonexistent-404
Add HTTP 404 error on actions for non-existent notes
Diffstat (limited to '')
-rw-r--r-- | lib/web/note/controller.js | 2 | ||||
-rw-r--r-- | lib/web/note/util.js | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/web/note/controller.js b/lib/web/note/controller.js index 45aea9e2..94bfa0e2 100644 --- a/lib/web/note/controller.js +++ b/lib/web/note/controller.js @@ -119,7 +119,7 @@ exports.doAction = function (req, res, next) { default: return res.redirect(config.serverURL + '/' + noteId) } - }) + }, null, false) } exports.downloadMarkdown = function (req, res, note) { diff --git a/lib/web/note/util.js b/lib/web/note/util.js index 57438515..effeb41c 100644 --- a/lib/web/note/util.js +++ b/lib/web/note/util.js @@ -5,7 +5,7 @@ const errors = require('../../errors') const fs = require('fs') const path = require('path') -exports.findNote = function (req, res, callback, include) { +exports.findNote = function (req, res, callback, include, createIfNotFound = true) { const id = req.params.noteId || req.params.shortid models.Note.parseNoteId(id, function (err, _id) { if (err) { @@ -18,9 +18,12 @@ exports.findNote = function (req, res, callback, include) { }, include: include || null }).then(function (note) { - if (!note) { + if (!note && createIfNotFound) { return exports.newNote(req, res, '') } + if (!note && !createIfNotFound) { + return errors.errorNotFound(res) + } if (!exports.checkViewPermission(req, note)) { return errors.errorForbidden(res) } else { |