Skip to content

Commit 55f7568

Browse files
authored
Merge pull request #966 from SISheogorath/fix/documentLength
Fix document length limit on post
2 parents eb885af + 353642c commit 55f7568

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/response.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ var response = {
3232
errorBadRequest: function (res) {
3333
responseError(res, '400', 'Bad Request', 'something not right.')
3434
},
35+
errorTooLong: function (res) {
36+
responseError(res, '413', 'Payload Too Large', 'Shorten your note!')
37+
},
3538
errorInternalError: function (res) {
3639
responseError(res, '500', 'Internal Error', 'wtf.')
3740
},
@@ -145,7 +148,12 @@ function responseCodiMD (res, note) {
145148

146149
function newNote (req, res, next) {
147150
var owner = null
148-
var body = req.body ? req.body : ''
151+
var body = ''
152+
if (req.body && req.body.length > config.documentMaxLength) {
153+
return response.errorTooLong(res)
154+
} else {
155+
body = req.body
156+
}
149157
body = body.replace(/[\r]/g, '')
150158
if (req.isAuthenticated()) {
151159
owner = req.user.id

0 commit comments

Comments
 (0)