From 180839bddd484089fdf1b28cd3c7d52b72908f63 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 4 Oct 2025 09:53:49 +0200 Subject: [PATCH] unicodeToHtmlEntities: Fix PHP 8.2 deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mbstring extension in PHP 8.2 deprecates `HTML-ENTITIES` encoding: https://php.watch/versions/8.2/mbstring-qprint-base64-uuencode-html-entities-deprecated Let’s switch to non-deprecated function: https://www.php.net/manual/en/function.mb-encode-numericentity.php --- Mf2/Parser.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Mf2/Parser.php b/Mf2/Parser.php index c7cc02d..d8d18d0 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -93,7 +93,12 @@ function fetch($url, $convertClassic = true, &$curlInfo=null) { * @return string */ function unicodeToHtmlEntities($input) { - return mb_convert_encoding($input, 'HTML-ENTITIES', mb_detect_encoding($input)); + // Convert all non-ASCII characters to HTML numeric entities. + $convmap = [ + 0x80, 0x1FFFFF, 0, 0x10FFFF, + ]; + + return mb_encode_numericentity($input, $convmap, mb_detect_encoding($input), true); } /**