fix some incorrect behaviour and messages in makepost

indiachan-spamvector
Thomas Lynch 3 years ago
parent 6f8db11684
commit c6978788f3
  1. 2
      controllers/forms/boardsettings.js
  2. 8
      controllers/forms/makepost.js

@ -25,7 +25,7 @@ module.exports = {
const { globalLimits, rateLimitCost } = config.get
, maxThread = (Math.min(globalLimits.fieldLength.message, res.locals.board.settings.maxThreadMessageLength) || globalLimits.fieldLength.message)
, maxReply = (Math.min(globalLimits.fieldLength.message, res.locals.board.settings.maxReplyMessageLength) || globalLimits.fieldLength.message);
const errors = await checkSchema([
{ result: lengthBody(req.body.description, 0, globalLimits.fieldLength.description), expected: false, error: `Board description must be ${globalLimits.fieldLength.description} characters or less` },
{ result: lengthBody(req.body.announcements, 0, 5000), expected: false, error: 'Board announcements must be 5000 characters or less' },

@ -31,7 +31,7 @@ module.exports = {
{ result: (res.locals.anonymizer && (disableAnonymizerFilePosting || res.locals.board.settings.disableAnonymizerFilePosting)
&& res.locals.numFiles > 0), expected: false, error: `Posting files through anonymizers has been disabled ${disableAnonymizerFilePosting ? 'globally' : 'on this board'}` },
{ result: res.locals.numFiles > res.locals.board.settings.maxFiles, blocking: true, permLevel: 1, expected: true, error: `Too many files. Max files per post ${res.locals.board.settings.maxFiles < globalLimits.postFiles.max ? 'on this board ' : ''}is ${res.locals.board.settings.maxFiles}` },
{ result: (lengthBody(req.body.subject, 0, 0) && (!existsBody(req.body.thread)
{ result: (lengthBody(req.body.subject, 1) && (!existsBody(req.body.thread)
&& res.locals.board.settings.forceThreadSubject)), expected: false, error: 'Threads must include a subject' },
{ result: lengthBody(req.body.message, 1) && (!existsBody(req.body.thread)
&& res.locals.board.settings.forceThreadMessage), expected: false, error: 'Threads must include a message' },
@ -45,9 +45,9 @@ module.exports = {
{ result: existsBody(req.body.message) && !existsBody(req.body.thread) && lengthBody(req.body.message, res.locals.board.settings.minThreadMessageLength, res.locals.board.settings.maxThreadMessageLength),
expected: false, error: `Thread messages must be ${res.locals.board.settings.minThreadMessageLength}-${res.locals.board.settings.maxThreadMessageLength} characters` },
{ result: lengthBody(req.body.postpassword, 0, globalLimits.fieldLength.postpassword), expected: false, error: `Password must be ${globalLimits.fieldLength.postpassword} characters or less` },
{ result: lengthBody(req.body.name, 0, globalLimits.fieldLength.name), expected: false, error: `Password must be ${globalLimits.fieldLength.name} characters or less` },
{ result: lengthBody(req.body.subject, 0, globalLimits.fieldLength.subject), expected: false, error: `Password must be ${globalLimits.fieldLength.subject} characters or less` },
{ result: lengthBody(req.body.email, 0, globalLimits.fieldLength.email), expected: false, error: `Password must be ${globalLimits.fieldLength.email} characters or less` },
{ result: lengthBody(req.body.name, 0, globalLimits.fieldLength.name), expected: false, error: `Name must be ${globalLimits.fieldLength.name} characters or less` },
{ result: lengthBody(req.body.subject, 0, globalLimits.fieldLength.subject), expected: false, error: `Subject must be ${globalLimits.fieldLength.subject} characters or less` },
{ result: lengthBody(req.body.email, 0, globalLimits.fieldLength.email), expected: false, error: `Email must be ${globalLimits.fieldLength.email} characters or less` },
]);
if (errors.length > 0) {

Loading…
Cancel
Save