From 16b6544f9dc66e76ca23ae7c3780d6a2732cf5d4 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 20 Sep 2025 11:34:54 +0900 Subject: [PATCH] Fix null return value when regexp replace fails on invalid input --- common/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/functions.php b/common/functions.php index 84b923681..2e2080687 100644 --- a/common/functions.php +++ b/common/functions.php @@ -671,7 +671,7 @@ function utf8_mbencode($str): string $bytes = array(ord($m[0][0]), ord($m[0][1]), ord($m[0][2]), ord($m[0][3])); $codepoint = ((0x07 & $bytes[0]) << 18) + ((0x3F & $bytes[1]) << 12) + ((0x3F & $bytes[2]) << 6) + (0x3F & $bytes[3]); return '&#x' . dechex($codepoint) . ';'; - }, (string)$str); + }, (string)$str) ?? ''; } /** @@ -686,11 +686,11 @@ function utf8_normalize_spaces($str, bool $multiline = false): string { if ($multiline) { - return preg_replace(['/((?!\x0A)[\pZ\pC])+/u', '/\x20*\x0A\x20*/'], [' ', "\n"], (string)$str); + return preg_replace(['/((?!\x0A)[\pZ\pC])+/u', '/\x20*\x0A\x20*/'], [' ', "\n"], (string)$str) ?? ''; } else { - return preg_replace('/[\pZ\pC]+/u', ' ', (string)$str); + return preg_replace('/[\pZ\pC]+/u', ' ', (string)$str) ?? ''; } }