From 4bc69be4bce4089bfd15476695b4e401fec1e7fb Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 27 Jul 2024 15:21:06 +0200 Subject: [PATCH] bans.php: fix new_ban failing due to the message body being too big --- inc/bans.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inc/bans.php b/inc/bans.php index c6847a4a..0da89640 100644 --- a/inc/bans.php +++ b/inc/bans.php @@ -365,6 +365,14 @@ class Bans { openBoard($post['board']); $post['board'] = $board['uri']; + /* + * The body can be so long to make the json longer than 64KBs, causing the query to fail. + * Truncate it to a safe length (32KBs). It could probably be longer, but if the deleted body is THAT big + * already, the likelihood of it being just assorted spam/garbage is about 101%. + */ + // We're on UTF-8 only, right...? + $post['body'] = mb_strcut($post['body'], 0, 32768); + $query->bindValue(':post', json_encode($post)); } else $query->bindValue(':post', null, PDO::PARAM_NULL);