Summary | Wrong MIME type on address book exports |
Queue | Turba |
Queue Version | FRAMEWORK_5_2 |
Type | Bug |
State | Unconfirmed |
Priority | 2. Medium |
Owners | |
Requester | wahnes (at) uni-koeln (dot) de |
Created | 03/25/2021 (1511 days ago) |
Due | |
Updated | 03/25/2021 (1511 days ago) |
Assigned | |
Resolved | |
Milestone | |
Patch | Yes |
State ⇒ Unconfirmed
Priority ⇒ 2. Medium
Type ⇒ Bug
Summary ⇒ Wrong MIME type on address book exports
Queue ⇒ Turba
Milestone ⇒
Patch ⇒ Yes
New Attachment: turba-mime-typ-vcard-export.patch
using the vCard format (either version 2 or 3), the downloaded file's
MIME type is wrong. The HTTP header will be
Content-Type: text/calendar
when it should be
Content-Type: text/vcard
While a wrong MIME type normally is not the most important thing on
earth, it can have some undesired results. When this is combined with
"no browser sniffing" headers (i.e. "X-Content-Type-Options:
nosniff"), some browsers will not simply adopt the filename suggested
by the "Content-Disposition" header's filename field, which would read
"contacts.vcf" in this case. Instead, the browser will suggest saving
the file as "contacts.ics" because it has been declared an iCalendar
file (text/calendar). This in turn will be irritating for
non-tech-savvy users, as a file with this name will not be
automatically imported by a local contact management software.
The reason for the wrong MIME type seems to be that the
"Horde_Data_Vcard" class inherits directly from "Horde_Data_Imc". The
Horde_Data_Imc's "exportFile" method always uses the "text/calendar"
MIME type when making files available for download.
I saw in the neighboring Horde_Data_Csv class that there is a field
called "_contentType" which may allow not to duplicate
Horde_Data_Imc's exportFile method for use with Horde_Data_Vcard, but
merely adjust the MIME type when downloading. However, my practical
knowledge of PHP's object model and is not sufficient to actually make
use of non-duplicated code here. As a result, the attached patch is
probably not the right way to do it, but it does solve the problem at
hand.