Skip to content

Node.js based forum software built for the modern web

fixes logic that allowed posts beyond maximum post length if min is set to 0, @barisusakli

Julian Lam3bd02d58e392
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index f50c9e53fa..d5b586d627 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -22,7 +22,7 @@ require('./posts/bookmarks')(SocketPosts);
require('./posts/tools')(SocketPosts);
SocketPosts.reply = function (socket, data, callback) {
- if (!data || !data.tid || !data.content) {
+ if (!data || !data.tid || (parseInt(meta.config.minimumPostLength, 10) !== 0 && !data.content)) {
return callback(new Error('[[error:invalid-data]]'));
}
diff --git a/src/topics/create.js b/src/topics/create.js
index 35f4e466a1..f5a51e7e77 100644
--- a/src/topics/create.js
+++ b/src/topics/create.js
@@ -105,10 +105,6 @@ module.exports = function (Topics) {
data.content = utils.rtrim(data.content);
}
- if (parseInt(meta.config.minimumPostLength, 10) === 0) {
- // Abort if minimum post length is set to 0
- return setImmediate(next);
- }
check(data.content, meta.config.minimumPostLength, meta.config.maximumPostLength, 'content-too-short', 'content-too-long', next);
},
function (next) {
@@ -350,7 +346,7 @@ module.exports = function (Topics) {
item = S(item).stripTags().s.trim();
}
- if (!item || item.length < parseInt(min, 10)) {
+ if (item === null || item === undefined || item.length < parseInt(min, 10)) {
return callback(new Error('[[error:' + minError + ', ' + min + ']]'));
} else if (item.length > parseInt(max, 10)) {
return callback(new Error('[[error:' + maxError + ', ' + max + ']]'));