mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 15:30:39 +01:00
fixes logic that allowed posts beyond maximum post length if min is set to 0, @barisusakli
This commit is contained in:
@@ -22,7 +22,7 @@ require('./posts/bookmarks')(SocketPosts);
|
|||||||
require('./posts/tools')(SocketPosts);
|
require('./posts/tools')(SocketPosts);
|
||||||
|
|
||||||
SocketPosts.reply = function (socket, data, callback) {
|
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]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,10 +105,6 @@ module.exports = function (Topics) {
|
|||||||
data.content = utils.rtrim(data.content);
|
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);
|
check(data.content, meta.config.minimumPostLength, meta.config.maximumPostLength, 'content-too-short', 'content-too-long', next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
@@ -350,7 +346,7 @@ module.exports = function (Topics) {
|
|||||||
item = S(item).stripTags().s.trim();
|
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 + ']]'));
|
return callback(new Error('[[error:' + minError + ', ' + min + ']]'));
|
||||||
} else if (item.length > parseInt(max, 10)) {
|
} else if (item.length > parseInt(max, 10)) {
|
||||||
return callback(new Error('[[error:' + maxError + ', ' + max + ']]'));
|
return callback(new Error('[[error:' + maxError + ', ' + max + ']]'));
|
||||||
|
|||||||
Reference in New Issue
Block a user