Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php 8.2 deprecation utf8_decode/utf8_encode #38258

Closed
brianteeman opened this issue Jul 12, 2022 · 1 comment
Closed

php 8.2 deprecation utf8_decode/utf8_encode #38258

brianteeman opened this issue Jul 12, 2022 · 1 comment
Labels
No Code Attached Yet PHP 8.x PHP 8.x deprecated issues

Comments

@brianteeman
Copy link
Contributor

php 8.2 will shortly be entering beta phase. Although there are not as many deprecations as in 8.1 we were very much behind the curve with 8.1 and we should be more proactive and look at this deprecations now.

Deprecate and Remove utf8_encode and utf8_decode

More information in the RFC

if (
preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $value) || strlen(utf8_decode($value)) < 2
|| $filterInput->clean($value, 'TRIM') !== $value
|| strlen(utf8_decode($value)) > $element['size']

if ($username) {
$isUsernameCompliant = !(preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $username) || strlen(utf8_decode($username)) < 2
|| trim($username) !== $username);

protected function decode($source)
{
static $ttr;
if (!\is_array($ttr)) {
// Entity decode
$trans_tbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
foreach ($trans_tbl as $k => $v) {
$ttr[$v] = utf8_encode($k);
}
}
$source = strtr($source, $ttr);
// Convert decimal
$source = preg_replace_callback(
'/&#(\d+);/m',
function ($m) {
return utf8_encode(\chr($m[1]));
},
$source
);
// Convert hex
$source = preg_replace_callback(
'/&#x([a-f0-9]+);/mi',
function ($m) {
return utf8_encode(\chr('0x' . $m[1]));
},
$source

@brianteeman
Copy link
Contributor Author

Closed see #39583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Code Attached Yet PHP 8.x PHP 8.x deprecated issues
Projects
None yet
Development

No branches or pull requests

3 participants