Skip to content
Snippets Groups Projects
Commit 1fe81370 authored by Thomas Müller's avatar Thomas Müller
Browse files

fixing download of attachments where the filename is within the content-type...

fixing download of attachments where the filename is within the content-type and not the content-disposition - fixes #438
parent 85c5a096
No related branches found
No related tags found
No related merge requests found
......@@ -66,20 +66,20 @@ class Attachment {
$fetch_query->bodyPart($this->attachmentId);
$fetch_query->mimeHeader($this->attachmentId);
$headers = array_merge($headers, array(
$headers = array_merge($headers, [
'importance',
'list-post',
'x-priority'
));
]);
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, array(
$fetch_query->headers('imp', $headers, [
'cache' => true
));
]);
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$ids = new \Horde_Imap_Client_Ids($this->messageId);
$headers = $this->conn->fetch($this->mailBox, $fetch_query, array('ids' => $ids));
$headers = $this->conn->fetch($this->mailBox, $fetch_query, ['ids' => $ids]);
/** @var $fetch Horde_Imap_Client_Data_Fetch */
if (!isset($headers[$this->messageId])) {
throw new DoesNotExistException('Unable to load the attachment.');
......@@ -97,16 +97,22 @@ class Attachment {
$this->mimePart->setDisposition('attachment');
// Extract headers from part
$vars = array(
'filename',
);
$contentDisposition = $mimeHeaders->getValue('content-disposition', \Horde_Mime_Headers::VALUE_PARAMS);
if (!is_null($contentDisposition)) {
$vars = ['filename'];
foreach ($contentDisposition as $key => $val) {
if(in_array($key, $vars)) {
$this->mimePart->setDispositionParameter($key, $val);
}
}
} else {
$contentDisposition = $mimeHeaders->getValue('content-type', \Horde_Mime_Headers::VALUE_PARAMS);
$vars = ['name'];
foreach ($contentDisposition as $key => $val) {
if(in_array($key, $vars)) {
$this->mimePart->setContentTypeParameter($key, $val);
}
}
}
/* Content transfer encoding. */
......
......@@ -144,8 +144,7 @@ class MessagesController extends Controller
* @param string $attachmentId
* @return AttachmentDownloadResponse
*/
public function downloadAttachment($messageId, $attachmentId)
{
public function downloadAttachment($messageId, $attachmentId) {
$mailBox = $this->getFolder();
$attachment = $mailBox->getAttachment($messageId, $attachmentId);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment