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

Remove deprecated usage of function #310

Merged
merged 9 commits into from
Dec 19, 2024
Merged

Remove deprecated usage of function #310

merged 9 commits into from
Dec 19, 2024

Conversation

SergeiMV
Copy link
Contributor

@SergeiMV SergeiMV commented Dec 10, 2024

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)

@@ -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');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use htmlentities
image
Have you tried it?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.
image

* Fix tests

* Drop composer dev flag

* Support css-selector 6

* Drop php 8.1

* Update changelog
@funivan
Copy link
Member

funivan commented Dec 15, 2024

Please, rebased your branch based on the latest master.

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.25%. Comparing base (b03f9d3) to head (ff73409).
Report is 6 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@funivan funivan merged commit bfdb9e6 into xparse:master Dec 19, 2024
5 of 6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants