diff --git a/install/data/defaults.json b/install/data/defaults.json index 5507ad0822..778dee3838 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -27,6 +27,10 @@ "field": "minimumPostLength", "value": 8 }, + { + "field": "maximumPostLength", + "value": 32767 + }, { "field": "allowGuestSearching", "value": 0 diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.json index 47b0bf8938..0258b28154 100644 --- a/public/language/en_GB/error.json +++ b/public/language/en_GB/error.json @@ -46,6 +46,7 @@ "still-uploading": "Please wait for uploads to complete.", "content-too-short": "Please enter a longer post. Posts should contain at least %1 characters.", + "content-too-long": "Please enter a shorter post. Posts can't be longer than %1 characters.", "title-too-short": "Please enter a longer title. Titles should contain at least %1 characters.", "title-too-long": "Please enter a shorter title. Titles can't be longer than %1 characters.", "invalid-title": "Invalid title!", diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index 5a80616517..2836967416 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -406,6 +406,8 @@ define('composer', [ return composerAlert('[[error:invalid-title]]'); } else if (bodyEl.val().length < parseInt(config.minimumPostLength, 10)) { return composerAlert('[[error:content-too-short, ' + config.minimumPostLength + ']]'); + } else if (bodyEl.val().length > parseInt(config.maximumPostLength, 10)) { + return composerAlert('[[error:content-too-long, ' + config.maximumPostLength + ']]'); } var composerData = {}, action; diff --git a/src/controllers/api.js b/src/controllers/api.js index be4d8b2347..a3412e0d1d 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -23,6 +23,7 @@ apiController.getConfig = function(req, res, next) { config.minimumTitleLength = meta.config.minimumTitleLength; config.maximumTitleLength = meta.config.maximumTitleLength; config.minimumPostLength = meta.config.minimumPostLength; + config.minimumPostLength = meta.config.maximumPostLength; config.hasImageUploadPlugin = plugins.hasListeners('filter:uploadImage'); config.maximumProfileImageSize = meta.config.maximumProfileImageSize; config.minimumUsernameLength = meta.config.minimumUsernameLength; diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index d9f673067c..5baa38e9cb 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -261,6 +261,8 @@ SocketPosts.edit = function(socket, data, callback) { return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]')); } else if (!data.content || data.content.length < parseInt(meta.config.minimumPostLength, 10)) { return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]')); + } else if (data.content.length > parseInt(meta.config.maximumPostLength, 10)) { + return callback(new Error('[[error:content-too-long, ' + meta.config.maximumPostLength + ']]')); } // uid, pid, title, content, options diff --git a/src/topics/create.js b/src/topics/create.js index b3038911c1..2eb882da80 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -289,6 +289,8 @@ module.exports = function(Topics) { function checkContentLength(content, callback) { if (!content || content.length < parseInt(meta.config.miminumPostLength, 10)) { return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]')); + } else if (content.length > parseInt(meta.config.maximumPostLength, 10)) { + return callback(new Error('[[error:content-too-long, ' + meta.config.maximumPostLength + ']]')); } callback(); } diff --git a/src/views/admin/settings/post.tpl b/src/views/admin/settings/post.tpl index 15f65ef531..3cb55eac0e 100644 --- a/src/views/admin/settings/post.tpl +++ b/src/views/admin/settings/post.tpl @@ -49,6 +49,10 @@ +