diff options
-rw-r--r-- | lib/response.js | 10 | ||||
-rw-r--r-- | public/views/index/body.ejs | 2 |
2 files changed, 10 insertions, 2 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 diff --git a/public/views/index/body.ejs b/public/views/index/body.ejs index 5b5f7ed3..cdc0ee2d 100644 --- a/public/views/index/body.ejs +++ b/public/views/index/body.ejs @@ -153,7 +153,7 @@ © 2018 <a href="https://hackmd.io">CodiMD</a> | <a href="<%- url %>/s/release-notes" target="_blank"><%= __('Releases') %></a><% if(privacyStatement) { %> | <a href="<%- url %>/s/privacy" target="_blank"><%= __('Privacy') %></a><% } %><% if(termsOfUse) { %> | <a href="<%- url %>/s/terms-of-use" target="_blank"><%= __('Terms of Use') %></a><% } %> </p> <h6 class="social-foot"> - <%- __('Follow us on %s and %s.', '<a href="https://github.com/hackmdio/CodiMD" target="_blank"><i class="fa fa-github"></i> GitHub</a>, <a href="https://riot.im/app/#/room/#codimd:matrix.org" target="_blank"><i class="fa fa-comments"></i> Riot</a>') %> + <%- __('Follow us on %s and %s.', '<a href="https://github.com/hackmdio/CodiMD" target="_blank"><i class="fa fa-github"></i> GitHub</a>, <a href="https://riot.im/app/#/room/#codimd:matrix.org" target="_blank"><i class="fa fa-comments"></i> Riot</a>', '<a href="https://translate.codimd.org" target="_blank"><i class="fa fa-globe"></i> POEditor</a>') %> </h6> </div> </div> |