From eb480975cd6e87523d58a03323a119530aa997a3 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Wed, 27 Nov 2024 21:28:04 +0100 Subject: [PATCH 1/2] config.php: add op min and max body configuration options --- inc/config.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inc/config.php b/inc/config.php index d5cfc6d0..abc271d9 100644 --- a/inc/config.php +++ b/inc/config.php @@ -556,6 +556,11 @@ // Requires $config['strip_combining_chars'] = true; $config['max_combining_chars'] = 0; + // Maximum OP body length. + $config['max_body_op'] = 1800; + // Minimum OP body length. + $config['min_body_op'] = 0; + // Maximum post body length. $config['max_body'] = 1800; // Minimum post body length. From 531e246e2898115c928fc9239b2712b26d63735a Mon Sep 17 00:00:00 2001 From: Zankaria Date: Wed, 27 Nov 2024 21:28:25 +0100 Subject: [PATCH 2/2] post.php: check different body length values for op --- post.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/post.php b/post.php index 20da003b..d1a7c75b 100644 --- a/post.php +++ b/post.php @@ -1231,11 +1231,19 @@ function handle_post() 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 && mb_strlen($post['body']) > 0 && (mb_strlen($post['body']) < $config['min_body'])) { - error($config['error']['tooshort_body']); + if (!$mod) { + $min_body = $post['op'] ? $config['min_body_op'] : $config['min_body']; + $max_body = $post['op'] ? $config['max_body_op'] : $config['max_body']; + + $body_mb_len = mb_strlen($post['body']); + + if ($body_mb_len > 0 && $body_mb_len < $min_body) { + error($config['error']['tooshort_body']); + } + + if ($body_mb_len > $max_body) { + error($config['error']['toolong_body']); + } } if (mb_strlen($post['password']) > 20) { error(sprintf($config['error']['toolong'], 'password'));