From bacc951bba9208e75da63ecf2785c4113aca383c Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 15 Mar 2017 09:20:06 -0600 Subject: [PATCH] Fix zipped mail attachments with special characters in their names were not visible on all OSes --- mail/inc/class.mail_ui.inc.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index e3c505086f..84f5794af3 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -2959,13 +2959,16 @@ $filter['before']= date("d-M-Y", $cutoffdate2); ' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' . pathinfo($file['filename'], PATHINFO_EXTENSION); } - if (!($fp = Vfs::fopen($path.$file['filename'],'wb')) || + // Strip special characters to make sure the files are visible for all OS (windows has issues) + $target_name = iconv($file['charset'] ? $file['charset'] : $GLOBALS['egw_info']['server']['system_charset'], 'ASCII//IGNORE', $file['filename']); + + if (!($fp = Vfs::fopen($path.$target_name,'wb')) || !(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp))) { $success=false; - Framework::message("Unable to zip {$file['filename']}",'error'); + Framework::message("Unable to zip {$target_name}",'error'); } - if ($success) $file_list[] = $path.$file['filename']; + if ($success) $file_list[] = $path.$target_name; if ($fp) fclose($fp); } $this->mail_bo->closeConnection();