Skip to content

Commit 180839b

Browse files
committed
unicodeToHtmlEntities: Fix PHP 8.2 deprecation
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
1 parent af7522b commit 180839b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Mf2/Parser.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ function fetch($url, $convertClassic = true, &$curlInfo=null) {
9393
* @return string
9494
*/
9595
function unicodeToHtmlEntities($input) {
96-
return mb_convert_encoding($input, 'HTML-ENTITIES', mb_detect_encoding($input));
96+
// Convert all non-ASCII characters to HTML numeric entities.
97+
$convmap = [
98+
0x80, 0x1FFFFF, 0, 0x10FFFF,
99+
];
100+
101+
return mb_encode_numericentity($input, $convmap, mb_detect_encoding($input), true);
97102
}
98103

99104
/**

0 commit comments

Comments
 (0)