From 2eef77c6e349bc29d066068facd26b454d2392b6 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 09 Jan 2014 05:19:30 -0500
Subject: [PATCH] Fix issue where filesystem path was added to all-attachments (zip) file (#1489507)

---
 CHANGELOG                           |    1 +
 /dev/null                           |   34 ----------------------------------
 plugins/zipdownload/zipdownload.php |   23 +++++++++++++++--------
 3 files changed, 16 insertions(+), 42 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index c6a8bd0..ce6f9bc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix issues where filesystem path was added to all-attachments (zip) file (#1489507)
 - Fix case-sensitivity of email addresses handling on compose (#1485499)
 - Don't alter Message-ID of a draft when sending (#1489409)
 - Fix issue where deprecated syntax for HTML lists was not handled properly (#1488768)
diff --git a/plugins/zipdownload/CHANGELOG b/plugins/zipdownload/CHANGELOG
deleted file mode 100644
index 32b878e..0000000
--- a/plugins/zipdownload/CHANGELOG
+++ /dev/null
@@ -1,34 +0,0 @@
-Roundcube Webmail ZipDownload
-=============================
-
-2012-09-20
-==========
- * Added style for new Larry skin
- * Made plugin work with 0.8 version of Roundcube
- * Save attachments to temp files before adding to zip archive (memory!)
-
-2011 03 12
-==========
- * Convert charset for filenames inside zip
-
-2010 08 30
-==========
- * Get all messages in folder, not just the first page
-
-2010 08 12
-==========
- * Use $.inArray() instead of Array.indexOf()
-
-2010 08 07
-==========
- * Add the ability to download a folder as zip
- * Add the ability to download selection of messages as zip
- * Add config file to control download options
-
-2010 05 29
-==========
- * Remove tnef_decode, now done by message class (r3680)
-
-2010 02 21
-==========
- * First version
\ No newline at end of file
diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php
index 5943126..3e3516e 100644
--- a/plugins/zipdownload/zipdownload.php
+++ b/plugins/zipdownload/zipdownload.php
@@ -106,9 +106,20 @@
 		$zip->open($tmpfname, ZIPARCHIVE::OVERWRITE);
 
 		foreach ($message->attachments as $part) {
-			$pid = $part->mime_id;
-			$part = $message->mime_parts[$pid];
-			$disp_name = $this->_convert_filename($part->filename);
+			$pid      = $part->mime_id;
+			$part     = $message->mime_parts[$pid];
+			$filename = $part->filename;
+
+            if ($filename === null || $filename === '') {
+                $ext      = (array) rcube_mime::get_mime_extensions($part->mimetype);
+                $ext      = array_shift($ext);
+                $filename = $rcmail->gettext('messagepart') . ' ' . $pid;
+                if ($ext) {
+                    $filename .= '.' . $ext;
+                }
+            }
+
+			$disp_name = $this->_convert_filename($filename);
 
 			if ($part->body) {
 				$orig_message_raw = $part->body;
@@ -205,11 +216,7 @@
 			$subject = $this->_convert_filename($subject);
 			$subject = substr($subject, 0, 16);
 
-			if (isset($subject) && $subject !="")
-				$disp_name = $subject . ".eml";
-			else
-				$disp_name = "message_rfc822.eml";
-
+            $disp_name = ($subject ? $subject : 'message_rfc822') . ".eml";
 			$disp_name = $uid . "_" . $disp_name;
 
 			$tmpfn = tempnam($temp_dir, 'zipmessage');

--
Gitblit v1.9.1