Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2021-10-28 15:09:29 +0300
committerAleksander Machniak <alec@alec.pl>2021-10-28 15:09:29 +0300
commit13da16b36fbd6f6b8d035d7ebb4f581ce29ebed7 (patch)
tree4c3c778bec8578baa30be06a1919209599bcf338
parent4402605be9c16a60c4e7abb3379636b9508e676b (diff)
Fix charset conversion errors on PHP < 8 for charsets not supported by mbstring (#8252)
-rw-r--r--CHANGELOG.md1
-rw-r--r--program/lib/Roundcube/rcube_charset.php12
-rw-r--r--tests/Framework/Charset.php3
3 files changed, 12 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c3aa2f26a..b0f8038c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,6 +39,7 @@
- Fix regression in setting of contact listing name (#8260)
- Fix bug in Larry skin where headers toggle state was reset on full page preview (#8203)
- Fix bug where \u200b characters were added into the recipient input preventing mail delivery (#8269)
+- Fix charset conversion errors on PHP < 8 for charsets not supported by mbstring (#8252)
## Release 1.5.0
diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php
index b0b68136e..e0a2db0cd 100644
--- a/program/lib/Roundcube/rcube_charset.php
+++ b/program/lib/Roundcube/rcube_charset.php
@@ -281,7 +281,7 @@ class rcube_charset
}
$out = false;
- $error_handler = function() use ($out) { $out = false; };
+ $error_handler = function() { throw new \Exception(); };
// Ignore invalid characters
$mbstring_sc = mb_substitute_character();
@@ -328,10 +328,14 @@ class rcube_charset
// If iconv reports an illegal character in input it means that input string
// has been truncated. It's reported as E_NOTICE.
// PHP8 will also throw E_WARNING on unsupported encoding.
- set_error_handler($error_handler, E_NOTICE);
- set_error_handler($error_handler, E_WARNING);
+ set_error_handler($error_handler, E_NOTICE | E_WARNING);
- $out = iconv($from, $to . $iconv_options, $str);
+ try {
+ $out = iconv($from, $to . $iconv_options, $str);
+ }
+ catch (Throwable $e) {
+ $out = false;
+ }
restore_error_handler();
diff --git a/tests/Framework/Charset.php b/tests/Framework/Charset.php
index 1284a2fae..38e217c2e 100644
--- a/tests/Framework/Charset.php
+++ b/tests/Framework/Charset.php
@@ -72,6 +72,9 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
if (extension_loaded('iconv')) {
// Windows-1253 is not supported by mbstring, we're testing fallback to iconv
$data[] = ['ε', chr(hexdec(('E5'))), 'UTF-8', 'WINDOWS-1253'];
+ // Windows-874 is also not supported by mbstring
+ $in = quoted_printable_decode('=B5=CD=BA=A1=C5=D1=BA');
+ $data[] = [$in, 'ตอบกลับ', 'WINDOWS-874', 'UTF-8'];
}
return $data;