"Unusual" file types not accepted with Safari
| Project: | ProjectPier |
| Version: | 0.8.0.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | new |
I couldn't upload some files with Safari. I get the message "Unknown file type".
The same file would be accepted with Firefox. (both on Mac, but I believe it would be true for Windows too)
Amongst the files that caused problems were files with extension .patch, .sql.
To reproduce, try to upload a file with one of these extensions using Safari.
The error is raised during the validation of the ProjectFileRevision associated with the new file and seems due to the fact that Safari gives an empty "type" string for uploaded files with unknown types.
(this is one post that mentions that too)
See line 387 of ProjectFileRevision.class.php.
You can confirm that by doing a dump of $_FILES.
Example:
array(1) { ["file_file"]=> array(5) { ["name"]=> string(18) "userhomepage.patch" ["type"]=> string(0) "" ["tmp_name"]=> string(36) "/Applications/MAMP/tmp/php/phpUHtrcf" ["error"]=> int(0) ["size"]=> int(9947) } }
whereas Firefox gives:
array(1) { ["file_file"]=> array(5) { ["name"]=> string(18) "userhomepage.patch" ["type"]=> string(24) "application/octet-stream" ["tmp_name"]=> string(36) "/Applications/MAMP/tmp/php/phpsF7c7y" ["error"]=> int(0) ["size"]=> int(9947) } }
I suppose the way to fix this would be to force the type string to "application/octet-stream" (or maybe something else? I'm not too familiar with these) if it's empty.
Any thoughts? Could it break anything?
