From 20a25197f3e2c51fb42db0832dc22d493334f20f Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 19 Sep 2008 16:20:39 +0000 Subject: applied tensor's patch: incorrect handling of filename of second and subsequent long non-ASCII attachments --- program/include/rcube_imap.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 0a90fedbe..ad56a3a74 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -1198,9 +1198,10 @@ class rcube_imap } // some servers (eg. dovecot-1.x) have no support for parameter value continuations // we must fetch and parse headers "manually" + //TODO: fetching headers for a second time is not effecient, this code should be moved somewhere earlier --tensor if ($i<2) { // TODO: fetch only Content-Type/Content-Disposition header - $headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER'); + $headers = iil_C_FetchPartHeader($this->conn, $this->mailbox, $this->_msg_id, $part->mime_id); $filename_mime = ''; $i = 0; while (preg_match('/filename\*'.$i.'\s*=\s*"*([^"\n;]+)[";]*/', $headers, $matches)) { @@ -1216,9 +1217,9 @@ class rcube_imap $filename_encoded .= $part->d_parameters['filename*'.$i.'*']; } if ($i<2) { - $headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER'); + $headers = iil_C_FetchPartHeader($this->conn, $this->mailbox, $this->_msg_id, $part->mime_id); $filename_encoded = ''; - $i = 0; + $i = 0; $matches = array(); while (preg_match('/filename\*'.$i.'\*\s*=\s*"*([^"\n;]+)[";]*/', $headers, $matches)) { $filename_encoded .= $matches[1]; $i++; @@ -1232,9 +1233,9 @@ class rcube_imap $filename_mime .= $part->ctype_parameters['name*'.$i]; } if ($i<2) { - $headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER'); + $headers = iil_C_FetchPartHeader($this->conn, $this->mailbox, $this->_msg_id, $part->mime_id); $filename_mime = ''; - $i = 0; + $i = 0; $matches = array(); while (preg_match('/\s+name\*'.$i.'\s*=\s*"*([^"\n;]+)[";]*/', $headers, $matches)) { $filename_mime .= $matches[1]; $i++; @@ -1248,9 +1249,9 @@ class rcube_imap $filename_encoded .= $part->ctype_parameters['name*'.$i.'*']; } if ($i<2) { - $headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER'); + $headers = iil_C_FetchPartHeader($this->conn, $this->mailbox, $this->_msg_id, $part->mime_id); $filename_encoded = ''; - $i = 0; + $i = 0; $matches = array(); while (preg_match('/\s+name\*'.$i.'\*\s*=\s*"*([^"\n;]+)[";]*/', $headers, $matches)) { $filename_encoded .= $matches[1]; $i++; -- cgit v1.2.3