|
|
|
@ -160,7 +160,8 @@ class zipdownload extends rcube_plugin
|
|
|
|
|
|
|
|
|
|
$zip->close();
|
|
|
|
|
|
|
|
|
|
$filename = ($message->subject ?: 'roundcube') . '.zip';
|
|
|
|
|
$filename = ($this->_filename_from_subject($message->subject) ?: 'attachments') . '.zip';
|
|
|
|
|
|
|
|
|
|
$this->_deliver_zipfile($tmpfname, $filename);
|
|
|
|
|
|
|
|
|
|
// delete temporary files from disk
|
|
|
|
@ -247,12 +248,11 @@ class zipdownload extends rcube_plugin
|
|
|
|
|
fwrite($tmpfp, "\r\n");
|
|
|
|
|
}
|
|
|
|
|
else { // maildir
|
|
|
|
|
$subject = rcube_mime::decode_mime_string((string)$headers->subject);
|
|
|
|
|
$subject = rcube_mime::decode_header($headers->subject, $headers->charset);
|
|
|
|
|
$subject = $this->_filename_from_subject(mb_substr($subject, 0, 16));
|
|
|
|
|
$subject = $this->_convert_filename($subject);
|
|
|
|
|
$subject = substr($subject, 0, 16);
|
|
|
|
|
|
|
|
|
|
$disp_name = ($subject ?: 'message_rfc822') . ".eml";
|
|
|
|
|
$disp_name = $path . $uid . "_" . $disp_name;
|
|
|
|
|
$disp_name = $path . $uid . ($subject ? " $subject" : '') . '.eml';
|
|
|
|
|
|
|
|
|
|
$tmpfn = tempnam($temp_dir, 'zipmessage');
|
|
|
|
|
$tmpfp = fopen($tmpfn, 'w');
|
|
|
|
@ -317,9 +317,19 @@ class zipdownload extends rcube_plugin
|
|
|
|
|
*/
|
|
|
|
|
private function _convert_filename($str)
|
|
|
|
|
{
|
|
|
|
|
$str = rcube_charset::convert($str, RCUBE_CHARSET, $this->charset);
|
|
|
|
|
$str = strtr($str, array(':' => '', '/' => '-'));
|
|
|
|
|
|
|
|
|
|
return rcube_charset::convert($str, RCUBE_CHARSET, $this->charset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper function to convert message subject into filename
|
|
|
|
|
*/
|
|
|
|
|
private function _filename_from_subject($str)
|
|
|
|
|
{
|
|
|
|
|
$str = preg_replace('/[\t\n\r\0\x0B]+\s*/', ' ', $str);
|
|
|
|
|
|
|
|
|
|
return strtr($str, array(':' => '', '/' => '-'));
|
|
|
|
|
return trim($str, " ./_");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|