|
|
@ -1634,9 +1634,15 @@ class rcube_imap extends rcube_storage
|
|
|
|
// Example of structure for malformed MIME message:
|
|
|
|
// Example of structure for malformed MIME message:
|
|
|
|
// ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
|
|
|
|
// ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
|
|
|
|
if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain'
|
|
|
|
if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain'
|
|
|
|
&& strtolower($structure[0].'/'.$structure[1]) == 'text/plain') {
|
|
|
|
&& strtolower($structure[0].'/'.$structure[1]) == 'text/plain'
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
// A special known case "Content-type: text" (#1488968)
|
|
|
|
|
|
|
|
if ($headers->ctype == 'text') {
|
|
|
|
|
|
|
|
$structure[1] = 'plain';
|
|
|
|
|
|
|
|
$headers->ctype = 'text/plain';
|
|
|
|
|
|
|
|
}
|
|
|
|
// we can handle single-part messages, by simple fix in structure (#1486898)
|
|
|
|
// we can handle single-part messages, by simple fix in structure (#1486898)
|
|
|
|
if (preg_match('/^(text|application)\/(.*)/', $headers->ctype, $m)) {
|
|
|
|
else if (preg_match('/^(text|application)\/(.*)/', $headers->ctype, $m)) {
|
|
|
|
$structure[0] = $m[1];
|
|
|
|
$structure[0] = $m[1];
|
|
|
|
$structure[1] = $m[2];
|
|
|
|
$structure[1] = $m[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1660,13 +1666,23 @@ class rcube_imap extends rcube_storage
|
|
|
|
$struct = $this->structure_part($structure, 0, '', $headers);
|
|
|
|
$struct = $this->structure_part($structure, 0, '', $headers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// don't trust given content-type
|
|
|
|
// some workarounds on simple messages...
|
|
|
|
if (empty($struct->parts) && !empty($headers->ctype)) {
|
|
|
|
if (empty($struct->parts)) {
|
|
|
|
|
|
|
|
// ...don't trust given content-type
|
|
|
|
|
|
|
|
if (!empty($headers->ctype)) {
|
|
|
|
$struct->mime_id = '1';
|
|
|
|
$struct->mime_id = '1';
|
|
|
|
$struct->mimetype = strtolower($headers->ctype);
|
|
|
|
$struct->mimetype = strtolower($headers->ctype);
|
|
|
|
list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype);
|
|
|
|
list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ...and charset (there's a case described in #1488968 where invalid content-type
|
|
|
|
|
|
|
|
// results in invalid charset in BODYSTRUCTURE)
|
|
|
|
|
|
|
|
if (!empty($headers->charset) && $headers->charset != $struct->ctype_parameters['charset']) {
|
|
|
|
|
|
|
|
$struct->charset = $headers->charset;
|
|
|
|
|
|
|
|
$struct->ctype_parameters['charset'] = $headers->charset;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$headers->structure = $struct;
|
|
|
|
$headers->structure = $struct;
|
|
|
|
|
|
|
|
|
|
|
|
return $this->icache['message'] = $headers;
|
|
|
|
return $this->icache['message'] = $headers;
|
|
|
|