Merge branch 'min-body-op' into 'config'

Minimum body length specific for op

See merge request leftypol/leftypol!13
This commit is contained in:
Zankaria Auxa 2024-11-27 20:39:42 +00:00
commit 4c1ac32bda
2 changed files with 18 additions and 5 deletions

View file

@ -556,6 +556,11 @@
// Requires $config['strip_combining_chars'] = true; // Requires $config['strip_combining_chars'] = true;
$config['max_combining_chars'] = 0; $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. // Maximum post body length.
$config['max_body'] = 1800; $config['max_body'] = 1800;
// Minimum post body length. // Minimum post body length.

View file

@ -1231,11 +1231,19 @@ function handle_post()
if (mb_strlen($post['subject']) > 100) { if (mb_strlen($post['subject']) > 100) {
error(sprintf($config['error']['toolong'], 'subject')); error(sprintf($config['error']['toolong'], 'subject'));
} }
if (!$mod && mb_strlen($post['body']) > $config['max_body']) { if (!$mod) {
error($config['error']['toolong_body']); $min_body = $post['op'] ? $config['min_body_op'] : $config['min_body'];
} $max_body = $post['op'] ? $config['max_body_op'] : $config['max_body'];
if (!$mod && mb_strlen($post['body']) > 0 && (mb_strlen($post['body']) < $config['min_body'])) {
error($config['error']['tooshort_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) { if (mb_strlen($post['password']) > 20) {
error(sprintf($config['error']['toolong'], 'password')); error(sprintf($config['error']['toolong'], 'password'));