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: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated #173

Open
gharlan opened this issue Nov 25, 2021 · 4 comments

Comments

@gharlan
Copy link

gharlan commented Nov 25, 2021

Using the mbstring "encoding" HTML-ENTITIES is deprecated since PHP 8.2: php/php-src#7177

mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead

It is used here:

$elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');

@aidantwoods
Copy link
Collaborator

This should be resolved by the changes #172, the HTML encoding has been completely rewritten. I'll leave this open until that is merged.

@manngo
Copy link

manngo commented Oct 27, 2023

This should be resolved by the changes #172, the HTML encoding has been completely rewritten. I'll leave this open until that is merged.

This issue is getting quite old now, and there doesn’t seem to be any movement on it. Have we give up all hope?

Meanwhile, I was able to replace the offending line with:

$elementMarkup = mb_encode_numericentity(htmlentities($elementMarkup, ENT_QUOTES, 'UTF-8' ), [0x80, 0x10FFFF, 0, ~0], 'UTF-8' );

This is more-or-less copied from one of the comments on php.net. I have no idea what’s going on here.

@Lukas238
Copy link

Here is another option that works for me:

$elementMarkup = htmlspecialchars_decode(iconv('UTF-8', 'ISO-8859-1', htmlentities($elementMarkup, ENT_COMPAT, 'UTF-8')), ENT_QUOTES);

@PHLAK
Copy link

PHLAK commented Dec 4, 2024

Any chance on getting this resolved soon now that PHP 8.4 is out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants