1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-02 12:57:35 +01:00

Merge pull request #845 from Zankaria/post-body-length

Add min/max body length checks for OP only
This commit is contained in:
Lorenzo Yario 2024-12-02 08:47:05 -08:00 committed by GitHub
commit 7d989e43e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 7 deletions

View File

@ -576,8 +576,14 @@
// Maximum numbers of threads that can be created every hour on a board.
$config['max_threads_per_hour'] = 30;
// Maximum OP body length.
$config['max_body_op'] = 1800;
// Minimum OP body length. Ignored if force_body_op is set to false.
$config['min_body_op'] = 0;
// Maximum post body length.
$config['max_body'] = 1800;
// Minimum post body length.
$config['min_body'] = 0;
// Maximum number of lines allowed in a post.
$config['maximum_lines'] = 100;
// Maximum number of post body lines to show on the index page.

View File

@ -955,16 +955,36 @@ if (isset($_POST['delete'])) {
if (!$dropped_post) {
// Check string lengths
if (mb_strlen($post['name']) > 35)
if (mb_strlen($post['name']) > 35) {
error(sprintf($config['error']['toolong'], 'name'));
if (mb_strlen($post['email']) > 40)
}
if (mb_strlen($post['email']) > 40) {
error(sprintf($config['error']['toolong'], 'email'));
if (mb_strlen($post['subject']) > 100)
}
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 && 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']);