tracker issue : CF-3695879

select a category, or use search below
(searches all categories and all time range)
Title:

The accept attribute of cffile doesn't work with Microsoft Word DOCX files

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Joe Steinbring / Joe Steinbring (Joe Steinbring)

Created: 01/19/2014

Components: File Management

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final / CF11 Update5

Priority/Frequency: Major / All users will encounter

Locale/System: English / Platforms All

Vote Count: 2

Listed in the version 11.0.05.293506 Issues Fixed doc
Problem Description:

I have noticed that you can not use the accept attribute to limit a script to only allow uploading of docx files.  If you eliminate the accept attribute, docx files from MS Office and LibreOffice are reported by the results variable as 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'.  If you set the accept attribute to equal "application/vnd.openxmlformats-officedocument.wordprocessingml.document", it rejects the file from LibreOffice, saying that it is an "application/zip" file.  When you try to upload the file from MS Office 2010, it does accept the file but results variable reports the uploaded file as being "application/x-tika-ooxml".

Steps to Reproduce:

I used the same test script (https://gist.github.com/steinbring/8482307) on both CentOS/Apache/CF10 Standard and localhosted CF10 on Win7.  I used two test files.  One was created in MS Office 2010 and one was created in LibreOffice 4.2.0.2.  In both apps, I saved the test file as a docx file.

Actual Result:

In the case of the LibreOffice file, the accept attribute wrongfully blocked the file.  In the case of the MS Office file, it accepted the file but the MIME type of the uploaded file was reported incorrectly.

Expected Result:

I expected it to accept both files successfully.

Any Workarounds:

The only workaround I can think of is to not use the accept attribute.  It looks like cfdirectory does reliably report the correct MIME type.  You could blindly upload everything and anything and then check the file for correct / expected content after the fact.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3695879

External Customer Info:
External Company:  
External Customer Name: _CoderJoe_
External Customer Email:  
External Test Config: My Hardware and Environment details:



CentOS/Apache/CF10 Standard and localhosted CF10 on Win7.  The OOo extension is installed on the CentOS box.  It is not installed on the windows 7 box.

Attachments:

Comments:

I documented everything at: http://steinbring.net/2014/coldfusion-cffiles-accept-attribute-does-not-work-right/. There are some screenshots that may or may not be helpful.
Comment by External U.
13636 | January 19, 2014 01:16:51 AM GMT
There is of course a difference in the format between MS office and LibreOffice document which is causing the mimetype to differ. Starting with ColdFusion 10, the accept attribute in ColdFusion 10 takes comma separated list of extensions or mimetypes. So in this particular case, your accept attribute can possibly be ".doc, .docx". Would that address your problem?
Comment by Rupesh K.
13637 | January 19, 2014 11:38:55 PM GMT
@Rupesh In both MS Office and LibreOffice, I am saving the test document as a docx. They should theoretically be identical. The difference in how they are treated slightly differently does indicate that there are some slight differences but I think that is beside the point. Neither file is treated correctly by the cffile. The problem with using a comma delimited list of extensions, is that it isn't actually looking at the actual mime type of the file. I want to invoke the new enhanced functionality that is triggered by the "strict='true'" flag. So, in short, no that wouldn't address it.
Comment by External U.
13638 | January 20, 2014 04:31:45 PM GMT
having the same kind of problems
Vote by External U.
13641 | September 15, 2014 07:18:14 AM GMT
This is affecting a customer of mine running on CF 11. The only way they can get any ".doc" or ".docx" files uploaded (without accepting all MIME types) is to set the "accept" attribute as follows: accept = "application/x-tika-msoffice,application/x-tika-ooxml"
Vote by External U.
13642 | October 23, 2014 12:40:26 PM GMT
The fix for this bug is available in the pre-release build of ColdFusion 11 Update 5
Comment by CFwatson U.
13639 | February 20, 2015 09:25:05 AM GMT
Verified this is fixed in CF11 Update 5 (build 11,0,05,293506). Uploaded .docx's resultant content subtype using accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document" is vnd.openxmlformats-officedocument.wordprocessingml.document instead of x-tika-ooxml. Thanks!, -Aaron
Comment by External U.
13640 | November 19, 2015 02:11:59 AM GMT