Skip to content

Commit aa85520

Browse files
committed
unicodeTrim: 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 However, there is no need to use it to the UTF-8 representation of NBSP, one can just directly use `\u{0a}` (or `\xc2\x0a` for PHP < 7.0). Or, even better, we can enable `PCRE_UTF8` mode: https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php It is supposed to be available since PHP 5.1: https://www.phpbb.com/community/viewtopic.php?t=733515
1 parent a2c7c44 commit aa85520

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Mf2/Parser.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ function collapseWhitespace($str) {
111111
}
112112

113113
function unicodeTrim($str) {
114-
// this is cheating. TODO: find a better way if this causes any problems
115-
$str = str_replace(mb_convert_encoding('&nbsp;', 'UTF-8', 'HTML-ENTITIES'), ' ', $str);
116-
return preg_replace('/^\s+|\s+$/', '', $str);
114+
return preg_replace('/^\s+|\s+$/u', '', $str);
117115
}
118116

119117
/**

0 commit comments

Comments
 (0)