DiDOM icon indicating copy to clipboard operation
DiDOM copied to clipboard

[PHP 8.2] Avoid Mbstring `HTML-ENTITIES` deprecation

Open Ayesh opened this issue 3 years ago • 0 comments

In PHP 8.2, using the Base64, Uuencode, QPrint, and HTML Entity encodings are deprecated

There is one usage of the deprecated HTML-ENTITIES Mbstring encoder in \DiDom\Encoder::convertToHtmlEntities(), which relies on the buggy behavior of HTML-ENTITIES encoder, which does not encode characters that the htmlspecialchars function encodes.

This patch updates the direct HTML-ENTITIES encoding with three steps:

  1. Encodes the string to UTF-8 from the given encoding $encoding
  2. Encodes all HTML entities using htmlentities
  3. Decodes special chars (<>'"&) using htmlspecialchars

Thank you.

Ayesh avatar Jan 29 '22 21:01 Ayesh