From be4aa5ac948a4bdbe65c488cf88f135c89e57383 Mon Sep 17 00:00:00 2001 From: pichalite Date: Mon, 21 Mar 2016 21:13:36 +0000 Subject: [PATCH] add title length check to topic fork process --- src/topics/fork.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/topics/fork.js b/src/topics/fork.js index fa4633fdd6..948cb3207e 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -1,14 +1,14 @@ 'use strict'; -var async = require('async'), - winston = require('winston'), - - db = require('../database'), - user = require('../user'), - posts = require('../posts'), - privileges = require('../privileges'), - plugins = require('../plugins'); +var async = require('async'); +var winston = require('winston'); +var db = require('../database'); +var user = require('../user'); +var posts = require('../posts'); +var privileges = require('../privileges'); +var plugins = require('../plugins'); +var meta = require('../meta'); module.exports = function(Topics) { @@ -18,8 +18,10 @@ module.exports = function(Topics) { title = title.trim(); } - if (!title) { - return callback(new Error('[[error:invalid-title]]')); + if (title.length < parseInt(meta.config.minimumTitleLength, 10)) { + return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]')); + } else if (title.length > parseInt(meta.config.maximumTitleLength, 10)) { + return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]')); } if (!pids || !pids.length) {