Fix zipped mail attachments with special characters in their names were not visible on all OSes

This commit is contained in:
nathangray 2017-03-15 09:20:06 -06:00
parent c02c04509a
commit bacc951bba

View File

@ -2959,13 +2959,16 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' . ' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' .
pathinfo($file['filename'], PATHINFO_EXTENSION); 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))) !(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
{ {
$success=false; $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); if ($fp) fclose($fp);
} }
$this->mail_bo->closeConnection(); $this->mail_bo->closeConnection();