-
Notifications
You must be signed in to change notification settings - Fork 25
Description
With .doc files from older MS Word, libmagic via the buffer interface on Unbuntu 14 is unable to identify the mime type unless the entire file is passed in the buffer. (Perhaps this issue occurs with other MIME types as well.) Otherwise, the returned mime type is "application/CDFV2-corrupt", which should fail the content-type check. The user will be told that "application/CDFV2-corrupt" is not supported, which is not something they can deal with effectively. A partial work-around for this is to set mime_upload_length to the max file size supported so that the entire file contents are provided to libmagic. However, that has a remaining case where the user is unnecessarily misled by an error message:
- if the actual mime type is "application/msword" but the file size exceeds the limit (and thus mime_upload_length), the error presented to the user will be a mime type error (because not enough data was passed to libmagic) instead of a file length error.
This confusing message can be resolved simply by changing the order of the file size and mime type checks.
(For some use cases this still might not be a workable solution because of the need to process the file contents in memory. That could be mitigated by reading additional data if the data in a "small" buffer cannot be identified.)