parsedown-extra icon indicating copy to clipboard operation
parsedown-extra copied to clipboard

PHP 8.2: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated

Open gharlan opened this issue 4 years ago • 6 comments

Using the mbstring "encoding" HTML-ENTITIES is deprecated since PHP 8.2: https://github.com/php/php-src/pull/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: https://github.com/erusev/parsedown-extra/blob/fd33d68349630d18d56367712a64445a6e0bc83e/ParsedownExtra.php#L628

gharlan avatar Nov 25 '21 23:11 gharlan

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

aidantwoods avatar Nov 27 '21 20:11 aidantwoods

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.

manngo avatar Oct 27 '23 00:10 manngo