diff options
author | Cyrille Bollu <cyr.debian@bollu.be> | 2021-05-28 16:26:07 +0300 |
---|---|---|
committer | Cyrille Bollu <cyr.debian@bollu.be> | 2021-05-28 16:51:05 +0300 |
commit | 414cf414a24aae4134ef02b4807e8b137b9784a7 (patch) | |
tree | 1fa1286222431ce621627b77707e7ac174efc1c4 /lib/Attachment.php | |
parent | aa6bbb2e09687674a86801342d78188372ff1a38 (diff) |
Sets downloaded attachment type to 'text/calendar' instead of the default 'application-octet-stream'
when attachment is of type 'text/calendar'.
Signed-off-by: Cyrille Bollu <cyr.debian@bollu.be>
Diffstat (limited to 'lib/Attachment.php')
-rw-r--r-- | lib/Attachment.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Attachment.php b/lib/Attachment.php index 853139355..6ac195592 100644 --- a/lib/Attachment.php +++ b/lib/Attachment.php @@ -79,10 +79,6 @@ class Attachment { $this->mimePart = new \Horde_Mime_Part(); - // To prevent potential problems with the SOP we serve all files with the - // MIME type "application/octet-stream" - $this->mimePart->setType('application/octet-stream'); - // Serve all files with a content-disposition of "attachment" to prevent Cross-Site Scripting $this->mimePart->setDisposition('attachment'); @@ -102,6 +98,18 @@ class Attachment { $this->mimePart->setTransferEncoding($tmp); } + /* Content type */ + if (strstr($mimeHeaders->getValue('content-type'), 'text/calendar')) { + $this->mimePart->setType('text/calendar'); + if ($this->mimePart->getContentTypeParameter('name') === null) { + $this->mimePart->setContentTypeParameter('name', 'calendar.ics'); + } + } else { + // To prevent potential problems with the SOP we serve all files but calendar entries with the + // MIME type "application/octet-stream" + $this->mimePart->setType('application/octet-stream'); + } + $body = $fetch->getBodyPart($this->attachmentId); $this->mimePart->setContents($body); } |