-
Notifications
You must be signed in to change notification settings - Fork 15
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
Remove deprecated usage of function #310
Conversation
@@ -214,7 +214,18 @@ private function setData(string $data): self | |||
|
|||
if (static::DOCUMENT_HTML === $this->type) { | |||
$data = StringHelper::safeEncodeStr($data); | |||
$data = mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8'); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using only htmlentities, some special characters will remain encoded, as shown in the screenshot above. To decode them, you need to use htmlspecialchars_decode, and also use mb_encode_numericentity to properly handle characters in UTF-8 encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give an example when special symbols are not encoded? I want to check this strings on both converters current and a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that if you use only htmlentities
, then the characters "'&<>
will remain encoded and you will need to additionally use html_entity_decode
to convert them.
In addition, if you use only htmlentities
and html_entity_decode
, then in the tests I added you will see that in the second case, when "broken" characters are used, htmlentities
successfully removes them, but in the first test case, instead of "Текст текст" it will output ТекÑ... and so on.
* Fix tests * Drop composer dev flag * Support css-selector 6 * Drop php 8.1 * Update changelog
Please, rebased your branch based on the latest master. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #310 +/- ##
============================================
- Coverage 93.50% 93.25% -0.26%
Complexity 124 124
============================================
Files 14 14
Lines 308 326 +18
============================================
+ Hits 288 304 +16
- Misses 20 22 +2 ☔ View full report in Codecov by Sentry. |
The reason for the changes is that the encoding in html-entities is deprecated for all MBString functions starting with PHP 8.2. An alternative that was used as a replacement was suggested here: symfony/symfony#44281 (comment)