You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Method \Symfony\Component\String\AbstractString::toByteString throws ValueError exception when unsupported encoding for mb_convert_encoding is passed instead of using fallback iconv.
How to reproduce
u('žsžsý')->toByteString('windows-1250');
Throws ValueError with message mb_convert_encoding(): Argument #2 ($to_encoding) must be a valid encoding, "windows-1250" given.
Instead of returning ByteString with output of iconv
…eachable (Vincentv92)
This PR was squashed before being merged into the 5.4 branch.
Discussion
----------
[String] Method toByteString conversion using iconv is unreachable
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues | Fix#52489 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License | MIT
<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.
Additionally (see https://symfony.com/releases):
- Always add tests and ensure they pass.
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the latest branch.
- For new features, provide some code snippets to help understand usage.
- Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
- Never break backward compatibility (see https://symfony.com/bc).
-->
Originating from original issue:
>It is possible that nobody noticed that PHP 8.0 added ValueError exception https://www.php.net/manual/en/function.mb-convert-encoding so the code is not compatible with php >= 8.0
That seems indeed to be the case
Commits
-------
08a27c2 [String] Method toByteString conversion using iconv is unreachable
Symfony version(s) affected
5.4.30
Description
Method
\Symfony\Component\String\AbstractString::toByteString
throwsValueError
exception when unsupported encoding formb_convert_encoding
is passed instead of using fallbackiconv
.How to reproduce
u('žsžsý')->toByteString('windows-1250');
Throws
ValueError
with messagemb_convert_encoding(): Argument #2 ($to_encoding) must be a valid encoding, "windows-1250" given
.Instead of returning
ByteString
with output oficonv
Possible Solution
No response
Additional Context
iconv('UTF-8', 'windows-1250', 'žsžsý')
returns expected value.Using PHP 8.1
It is possible that nobody noticed that PHP 8.0 added ValueError exception https://www.php.net/manual/en/function.mb-convert-encoding so the code is not compatible with php >= 8.0
The text was updated successfully, but these errors were encountered: