From 00ef061ef82a310241873209b237963e713cc5a2 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 17 Nov 2024 14:40:36 +0100 Subject: [PATCH] Fix PHP fatal error when parsing some malformed BODYSTRUCTURE responses (#9689) --- CHANGELOG.md | 1 + program/lib/Roundcube/rcube_imap.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd241f1783f..71bcf65f6a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ - Fix rcube_imap::get_vendor() result (and PHP warning) on Zimbra server (#9650) - Fix regression causing inline SVG images to be missing in mail preview (#9644) - Fix plugin "virtuser_file" to handle backward slashes in username (#9668) +- Fix PHP fatal error when parsing some malformed BODYSTRUCTURE responses (#9689) ## Release 1.6.9 diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index eb69615c5d0..cc41965a395 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -2282,7 +2282,7 @@ protected function structure_part($part, $count = 0, $parent = '', $mime_headers protected function is_attachment_part($part) { if (!empty($part[2]) && is_array($part[2]) && empty($part[3])) { - $params = array_map('strtolower', (array) $part[2]); + $params = array_map('strtolower', array_filter($part[2], 'is_string')); $find = ['name', 'filename', 'name*', 'filename*', 'name*0', 'filename*0', 'name*0*', 'filename*0*']; // In case of malformed header check disposition. E.g. some servers for @@ -2304,7 +2304,7 @@ protected function is_attachment_part($part) protected function structure_charset($structure) { while (is_array($structure)) { - if (is_array($structure[2]) && $structure[2][0] == 'charset') { + if (isset($structure[2]) && is_array($structure[2]) && $structure[2][0] == 'charset') { return $structure[2][1]; }