From 20a25197f3e2c51fb42db0832dc22d493334f20f Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 19 Sep 2008 12:20:39 -0400
Subject: [PATCH] applied tensor's patch: incorrect handling of filename of second and subsequent long non-ASCII attachments

---
 program/include/rcube_imap.php |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 0a90fed..ad56a3a 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -1198,9 +1198,10 @@
 	}
       // 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 @@
 	$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 @@
         $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 @@
         $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++;

--
Gitblit v1.9.1