summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph (Sheogorath) Kern2018-09-27 20:10:50 +0200
committerGitHub2018-09-27 20:10:50 +0200
commit55f7568985cc66edc42c7fae31b0e4c2e8990717 (patch)
tree9451f3fadc418cb7ef18915e2fb70e5ef94f90b7 /lib
parenteb885af995d9756d2d24021ddaef5e748568b501 (diff)
parent353642c870e569dfc251a5986a1586c8ce1b8450 (diff)
Merge pull request #966 from SISheogorath/fix/documentLength
Fix document length limit on post
Diffstat (limited to '')
-rw-r--r--lib/response.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/response.js b/lib/response.js
index 295f91d6..8133b1a0 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -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