Support cleaning hex colours from punishment reasons

This commit is contained in:
ruan 2023-07-18 16:01:20 +02:00
parent d56b589494
commit 8004989501

View File

@ -319,9 +319,12 @@ class Page {
*/ */
function clean($text) { function clean($text) {
if ($text === null) return null; if ($text === null) return null;
if (strstr($text, "\xa7") || strstr($text, "&")) { if (strstr($text, "\xa7") || strstr($text, "&")) { // Regular chat colours
$text = preg_replace("/(?i)(\x{00a7}|&)[0-9A-FK-OR]/u", "", $text); $text = preg_replace("/(?i)(\x{00a7}|&)[0-9A-FK-OR]/u", "", $text);
} }
if (strstr($text, "#")) { // Hex colours
$text = preg_replace("/(?i)#[0-9A-F]{6}/u", "", $text);
}
$text = htmlspecialchars($text, ENT_QUOTES); $text = htmlspecialchars($text, ENT_QUOTES);
if (strstr($text, "\\n")) { if (strstr($text, "\\n")) {
$text = preg_replace("/\\\\n/", "<br>", $text); $text = preg_replace("/\\\\n/", "<br>", $text);