29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-17 17:44:57 +00:00

[4.2] PHP8.2 Replace deprecated utf8 encode/decode to mb string (#39583)

* Replace deprecated utf8 encode/decode to mb string

* Make mb string polyfill dependency explicit

* Order
This commit is contained in:
Allon Moritz 2023-01-14 12:01:48 +01:00 committed by GitHub
parent cff0c4b369
commit 72af961e21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 7 deletions

View File

@ -130,7 +130,8 @@ class ProfileModel extends FormModel
$username = $loadData ? $form->getValue('username') : $this->loadFormData()->username;
if ($username) {
$isUsernameCompliant = !(preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $username) || strlen(utf8_decode($username)) < 2
$isUsernameCompliant = !(preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $username)
|| strlen(mb_convert_encoding($username, 'ISO-8859-1', 'UTF-8')) < 2
|| trim($username) !== $username);
}

View File

@ -79,6 +79,7 @@
"symfony/error-handler": "^5.2",
"symfony/ldap": "~5.0",
"symfony/options-resolver": "~5.0",
"symfony/polyfill-mbstring": "^1.27",
"symfony/polyfill-php73": "^1.10",
"symfony/web-link": "~5.0",
"symfony/yaml": "~5.0",

2
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "247b8d364f7a520d56a83ae603d724fd",
"content-hash": "b222d41120c26888bac6ad7d07737286",
"packages": [
{
"name": "algo26-matthias/idna-convert",

View File

@ -43,9 +43,10 @@ class UsernameRule extends FormRule
$filterInput = InputFilter::getInstance();
if (
preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $value) || strlen(utf8_decode($value)) < 2
preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $value)
|| strlen(mb_convert_encoding($value, 'ISO-8859-1', 'UTF-8')) < 2
|| $filterInput->clean($value, 'TRIM') !== $value
|| strlen(utf8_decode($value)) > $element['size']
|| strlen(mb_convert_encoding($value, 'ISO-8859-1', 'UTF-8')) > $element['size']
) {
return false;
}

View File

@ -435,7 +435,7 @@ class InputFilter extends BaseInputFilter
$trans_tbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
foreach ($trans_tbl as $k => $v) {
$ttr[$v] = utf8_encode($k);
$ttr[$v] = mb_convert_encoding($k, 'UTF-8', 'ISO-8859-1');
}
}
@ -445,7 +445,7 @@ class InputFilter extends BaseInputFilter
$source = preg_replace_callback(
'/&#(\d+);/m',
function ($m) {
return utf8_encode(\chr($m[1]));
return mb_convert_encoding(\chr($m[1]), 'UTF-8', 'ISO-8859-1');
},
$source
);
@ -454,7 +454,7 @@ class InputFilter extends BaseInputFilter
$source = preg_replace_callback(
'/&#x([a-f0-9]+);/mi',
function ($m) {
return utf8_encode(\chr('0x' . $m[1]));
return mb_convert_encoding(\chr('0x' . $m[1]), 'UTF-8', 'ISO-8859-1');
},
$source
);