mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
Fix document length limit on post
We recently introduced a new way to create notes using a post requeest to the `/new` endpoint. This is not limited in size, other than pasting a note in the editor. This patch should enforce this limit also on this way. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
This commit is contained in:
parent
bdf897d31c
commit
353642c870
1 changed files with 9 additions and 1 deletions
|
@ -32,6 +32,9 @@ var response = {
|
|||
errorBadRequest: function (res) {
|
||||
responseError(res, '400', 'Bad Request', 'something not right.')
|
||||
},
|
||||
errorTooLong: function (res) {
|
||||
responseError(res, '413', 'Payload Too Large', 'Shorten your note!')
|
||||
},
|
||||
errorInternalError: function (res) {
|
||||
responseError(res, '500', 'Internal Error', 'wtf.')
|
||||
},
|
||||
|
@ -145,7 +148,12 @@ function responseCodiMD (res, note) {
|
|||
|
||||
function newNote (req, res, next) {
|
||||
var owner = null
|
||||
var body = req.body ? req.body : ''
|
||||
var body = ''
|
||||
if (req.body && req.body.length > config.documentMaxLength) {
|
||||
return response.errorTooLong(res)
|
||||
} else {
|
||||
body = req.body
|
||||
}
|
||||
body = body.replace(/[\r]/g, '')
|
||||
if (req.isAuthenticated()) {
|
||||
owner = req.user.id
|
||||
|
|
Loading…
Reference in a new issue