summaryrefslogtreecommitdiff
path: root/program/lib
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-12-23 08:01:39 +0000
committeralecpl <alec@alec.pl>2009-12-23 08:01:39 +0000
commitaa16b4af8f67d91b1bfd2c584a665a53c403f47c (patch)
treed151af266514e0d7ea956b4cd224923940cbdc93 /program/lib
parentbe11a9fcfcc79c87db6777ee08540bca84489f1d (diff)
- Improved handling of message parts of type message/rfc822 (fixed e.g. inline images in multipart/alternative messages attached as message/rfc822)
Diffstat (limited to 'program/lib')
-rw-r--r--program/lib/imap.inc9
1 files changed, 5 insertions, 4 deletions
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 409c2622b..17225c177 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -2136,7 +2136,7 @@ function iil_C_UnSubscribe(&$conn, $folder) {
return (iil_ParseResult($line) == 0);
}
-function iil_C_FetchMIMEHeaders(&$conn, $mailbox, $id, $parts) {
+function iil_C_FetchMIMEHeaders(&$conn, $mailbox, $id, $parts, $mime=true) {
$fp = $conn->fp;
@@ -2149,10 +2149,11 @@ function iil_C_FetchMIMEHeaders(&$conn, $mailbox, $id, $parts) {
$key = 'fmh0';
$peeks = '';
$idx = 0;
+ $type = $mime ? 'MIME' : 'HEADER';
// format request
foreach($parts as $part)
- $peeks[] = "BODY.PEEK[$part.MIME]";
+ $peeks[] = "BODY.PEEK[$part.$type]";
$request = "$key FETCH $id (" . implode(' ', $peeks) . ')';
@@ -2165,9 +2166,9 @@ function iil_C_FetchMIMEHeaders(&$conn, $mailbox, $id, $parts) {
$line = iil_ReadLine($fp, 1000);
$line = iil_MultLine($fp, $line);
- if (preg_match('/BODY\[([0-9\.]+)\.MIME\]/', $line, $matches)) {
+ if (preg_match('/BODY\[([0-9\.]+)\.'.$type.'\]/', $line, $matches)) {
$idx = $matches[1];
- $result[$idx] = preg_replace('/^(\* '.$id.' FETCH \()?\s*BODY\['.$idx.'\.MIME\]\s+/', '', $line);
+ $result[$idx] = preg_replace('/^(\* '.$id.' FETCH \()?\s*BODY\['.$idx.'\.'.$type.'\]\s+/', '', $line);
$result[$idx] = trim($result[$idx], '"');
$result[$idx] = rtrim($result[$idx], "\t\r\n\0\x0B");
}