File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
146149function 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
You can’t perform that action at this time.
0 commit comments