summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-08-09 13:30:17 +0000
committeralecpl <alec@alec.pl>2010-08-09 13:30:17 +0000
commit3c9d9aa94395a93585c5df779e690e5f16cf6374 (patch)
tree65a070bb2c36a4c7ef1da30644f90db859ff661b
parent119ad13d74388ed62144724ac22e7cc24588eb6b (diff)
- Improve handling of single-part messages with bogus BODYSTRUCTURE (#1486898)
-rw-r--r--CHANGELOG2
-rw-r--r--program/include/rcube_imap.php16
2 files changed, 14 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index e881ce230..fbb721bad 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
CHANGELOG RoundCube Webmail
===========================
+- Improve handling of single-part messages with bogus BODYSTRUCTURE (#1486898)
+
RELEASE 0.4
-----------
- Fix disapearing upload form disapears when user selects a file on Safari (#1486823)
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 4dd46e95f..57667229d 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -1704,14 +1704,22 @@ class rcube_imap
else
$this->struct_charset = $this->_structure_charset($structure);
+ $headers->ctype = strtolower($headers->ctype);
+
// Here we can recognize malformed BODYSTRUCTURE and
// 1. [@TODO] parse the message in other way to create our own message structure
// 2. or just show the raw message body.
// Example of structure for malformed MIME message:
- // ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 2154 70 NIL NIL NIL)
- if ($headers->ctype && $headers->ctype != 'text/plain'
- && $structure[0] == 'text' && $structure[1] == 'plain') {
- return false;
+ // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
+ if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain'
+ && strtolower($structure[0].'/'.$structure[1]) == 'text/plain') {
+ // we can handle single-part messages, by simple fix in structure (#1486898)
+ if (preg_match('/^(text|application)\/(.*)/i', $headers->ctype, $m)) {
+ $structure[0] = $m[1];
+ $structure[1] = $m[2];
+ }
+ else
+ return false;
}
$struct = &$this->_structure_part($structure);