-
Notifications
You must be signed in to change notification settings - Fork 309
Description
Steps to reproduce
- Receive or place an email in the inbox with the header specifying charset="ks_c_5601-1987".
- Open the Nextcloud Mail app and navigate to the Inbox.
- The Inbox fails to load (endless spinner or empty list).
- Check the Nextcloud logs to see the fatal exception.
Expected behavior
The Mail app should handle unsupported legacy charsets gracefully (for instance, by mapping them to supported aliases like EUC-KR or catching the ValueError) and load the rest of the inbox without crashing.
Actual behavior
The application throws a fatal exception and stops the execution, preventing the user from accessing their mailbox.
Mail app version
5.6.14
Nextcloud version
31.0.14
Mailserver or service
Dovecot imap own server
Operating system
Ubuntu 24.04
PHP engine version
PHP 8.3
Nextcloud memory caching
'memcache.local' => '\OC\Memcache\APCu', 'memcache.distributed' => '\OC\Memcache\Redis',
Web server
Nginx
Database
MariaDB
Additional info
When an email in the inbox uses the legacy Korean charset ks_c_5601-1987, the Mail app completely fails to load the message list. This happens because PHP 8+ is strict and throws a fatal ValueError when an unsupported encoding is passed to mb_convert_encoding(), instead of failing gracefully. Since the ValueError exception is not caught, the entire request crashes.
A simple workaround is to map the unsupported ks_c_5601-1987 charset to the valid EUC-KR alias before processing the conversion in lib/IMAP/Charset/Converter.php.
// Inside OCA\Mail\IMAP\Charset\Converter::convert()
$charset = $p->getCharset();
// Map unsupported legacy Korean charset to EUC-KR to prevent PHP 8 ValueError
if (is_string($charset) && strtolower($charset) === 'ks_c_5601-1987') {
$charset = 'EUC-KR';
}
if ($charset !== null && strtoupper($charset) === 'UTF-8') {
return $data;
}
// ... rest of the code