From d9b983a3fbc55c89e1f84376f57f11baa0328b8d Mon Sep 17 00:00:00 2001 From: Zankaria Date: Wed, 27 Nov 2024 22:12:51 +0100 Subject: [PATCH] post.php: check post body min and max op characters --- post.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/post.php b/post.php index 29fe5b6f..6d05594b 100644 --- a/post.php +++ b/post.php @@ -964,14 +964,26 @@ if (isset($_POST['delete'])) { if (mb_strlen($post['subject']) > 100) { error(sprintf($config['error']['toolong'], 'subject')); } - if (!$mod && mb_strlen($post['body']) > $config['max_body']) { - error($config['error']['toolong_body']); - } - if (!$mod && $config['force_body'] && mb_strlen($post['body']) < $config['min_body']) { - error($config['error']['tooshort_body']); - } - if (!$mod && substr_count($post['body'], "\n") >= $config['maximum_lines']) { - error($config['error']['toomanylines']); + if (!$mod) { + $body_mb_len = mb_strlen($post['body']); + $is_op = $post['op']; + + if (($is_op && $config['force_body_op']) || (!$is_op && $config['force_body'])) { + $min_body = $is_op ? $config['min_body_op'] : $config['min_body']; + + if ($body_mb_len < $min_body) { + error($config['error']['tooshort_body']); + } + } + + $max_body = $is_op ? $config['max_body_op'] : $config['max_body']; + if ($body_mb_len > $max_body) { + error($config['error']['toolong_body']); + } + + if (substr_count($post['body'], '\n') >= $config['maximum_lines']) { + error($config['error']['toomanylines']); + } } } wordfilters($post['body']);