[GH-ISSUE #732] updating cypth and windows 1257 error on php 8.2 #457

Closed
opened 2026-02-25 21:35:05 +03:00 by kerem · 5 comments
Owner

Originally created by @mcbmcb0 on GitHub (Jul 14, 2023).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/732

💬 Question

I've updated to php 8.2.7 (from 7.3.3) and now see the following:
PHP Fatal error: Uncaught ValueError: mb_convert_encoding(): Argument #3 ($from_encoding) contains invalid encoding "windows-1257" in /var/www/cypht/modules/core/message_functions.php

  1. strangely, i don't even know if i have the current version of cypth as can't see a current version displayed nor find info on updating.... is it a reinstall or does it self update?
  2. if cypht is up to date... any clues on that mb_convert_encoding() error message?
    thanks!
Originally created by @mcbmcb0 on GitHub (Jul 14, 2023). Original GitHub issue: https://github.com/cypht-org/cypht/issues/732 ## 💬 Question I've updated to php 8.2.7 (from 7.3.3) and now see the following: `PHP Fatal error: Uncaught ValueError: mb_convert_encoding(): Argument #3 ($from_encoding) contains invalid encoding "windows-1257" in /var/www/cypht/modules/core/message_functions.php` 1. strangely, i don't even know if i have the current version of cypth as can't see a current version displayed nor find info on updating.... is it a reinstall or does it self update? 2. if cypht is up to date... any clues on that `mb_convert_encoding()` error message? thanks!
kerem closed this issue 2026-02-25 21:35:05 +03:00
Author
Owner

@mcbmcb0 commented on GitHub (Jul 15, 2023):

further, i noticed that the function creating the error is unchanged in the new cypht 1.4, and that this issue has appeared in nextcloud and roundcube as well - eg https://github.com/roundcube/roundcubemail/issues/1004. apparently for mb_convert_encoding():

as of PHP 8.0.0, a ValueError is thrown if the value of to_encoding or from_encoding is an invalid encoding. Prior to PHP 8.0.0, a E_WARNING was emitted instead.

adapting the roundcube patch i hacked this into message_functions.php:

$fld = substr($fld, (strpos($fld, '?') + 1)); // EXISTING line 403
      
$alt_charset = ['UTF-7'=>"UTF7-IMAP", 'WINDOWS-1257'=> "ISO-8859-13"]; 
if(array_key_exists(strtoupper($charset), $alt_charset)){// MB
   $charset = $alt_charset[strtoupper($charset)];
 }

if (strtoupper($encoding) == 'B') { // existing line 404
...

this appears to work. the array can obviously expand to other similar problems (eg windows 1250 and 1256 are reported as problems by some).
i tried using iconv for these character sets but had lots of 'Wrong encoding' errors so didn't bother.

this is temporary and not elegant but may help someone until a proper fix is found.

<!-- gh-comment-id:1636636936 --> @mcbmcb0 commented on GitHub (Jul 15, 2023): further, i noticed that the function creating the error is unchanged in the new cypht 1.4, and that this issue has appeared in nextcloud and roundcube as well - eg [https://github.com/roundcube/roundcubemail/issues/1004](https://github.com/roundcube/roundcubemail/issues/1004). apparently for mb_convert_encoding(): > as of PHP 8.0.0, a ValueError is thrown if the value of to_encoding or from_encoding is an invalid encoding. Prior to PHP 8.0.0, a E_WARNING was emitted instead. adapting the roundcube patch i hacked this into message_functions.php: ``` $fld = substr($fld, (strpos($fld, '?') + 1)); // EXISTING line 403 $alt_charset = ['UTF-7'=>"UTF7-IMAP", 'WINDOWS-1257'=> "ISO-8859-13"]; if(array_key_exists(strtoupper($charset), $alt_charset)){// MB $charset = $alt_charset[strtoupper($charset)]; } if (strtoupper($encoding) == 'B') { // existing line 404 ... ``` this appears to work. the array can obviously expand to other similar problems (eg windows 1250 and 1256 are reported as problems by some). i tried using iconv for these character sets but had lots of '`Wrong encoding`' errors so didn't bother. this is temporary and not elegant but may help someone until a proper fix is found.
Author
Owner

@marclaporte commented on GitHub (Jul 23, 2023):

Thank you @mcbmcb0

@josaphatim and I will investigate along with your other PHP8 report.

<!-- gh-comment-id:1646894877 --> @marclaporte commented on GitHub (Jul 23, 2023): Thank you @mcbmcb0 @josaphatim and I will investigate along with your other PHP8 report.
Author
Owner

@marclaporte commented on GitHub (Jul 23, 2023):

FYI, Cypht is bundled in Tiki so it will have a lot of extra eyeballs in this context:

FYI: Historically, Cypht tries to support a large number of PHP versions. I want to slowly move us in a direction where we keep up with new PHP versions and more frequent version releases. And we'll introduce Long Term Support (LTS) versions for those that want/need to use on older versions of PHP. Something closer to https://tiki.org/Tiki-Versions

<!-- gh-comment-id:1646898168 --> @marclaporte commented on GitHub (Jul 23, 2023): FYI, Cypht is bundled in Tiki so it will have a lot of extra eyeballs in this context: - https://doc.tiki.org/PHP8 - https://doc.tiki.org/Cypht FYI: Historically, Cypht tries to support a large number of PHP versions. I want to slowly move us in a direction where we keep up with new PHP versions and more frequent version releases. And we'll introduce Long Term Support (LTS) versions for those that want/need to use on older versions of PHP. Something closer to https://tiki.org/Tiki-Versions
Author
Owner

@marclaporte commented on GitHub (Sep 5, 2023):

@mcbmcb0 Please confirm the issue is solved in master.

<!-- gh-comment-id:1705813190 --> @marclaporte commented on GitHub (Sep 5, 2023): @mcbmcb0 Please confirm the issue is solved in master.
Author
Owner

@mcbmcb0 commented on GitHub (Sep 8, 2023):

yes! the current master appears to work for me on php8.2.
thanks

<!-- gh-comment-id:1711101663 --> @mcbmcb0 commented on GitHub (Sep 8, 2023): yes! the current master appears to work for me on php8.2. thanks
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#457
No description provided.