Page MenuHomePhabricator

Upload warning incorrect "File extension does not match MIME type." with URL encoded filenames
Closed, InvalidPublic

Description

When using "Source URL" "sideloading" to upload a file using the file's URL, if the file name contains URL-encoded characters, the warning "File extension does not match MIME type." is given. Removing the URL-encoded characters from the file name allows the upload to proceed, but the checkbox "Ignore any warnings" does not work.

I discovered the bug with this file, which has an URL encoded comma %2C after the word "Park":

http://commons.wikimedia.org/wiki/File:Gyps_rueppellii_-Nairobi_National_Park,_Kenya-8-4c.jpg

I'm not sure how this should be solved, since I don't know what characters are not allowed in a file name, if any. It may depend on the system. It might be a good idea to strip out characters that are allowed in URLs, but not in file names.


Version: 1.17.x
Severity: critical

Details

Reference
bz30043
TitleReferenceAuthorSource BranchDest Branch
OpenLDAP image for integration tests, based on Bookworm.repos/releng/dev-images!21slyngshedeopenldap-integration-testmain
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:50 PM
bzimport set Reference to bz30043.
bzimport added a subscriber: Unknown Object (MLST).

I increased this from "normal" to "critical" since there is no workaround for it. Users will always receive this error when they try to upload something with url-encoding (which is almost everything these days). This feature essentially does not work most of the time, at this point.

vivekee047 wrote:

@Badon:The problem is not in characters of the file..

*The Problem is in Guessing of Mime Type

In function verifyFile,the following code guesses the mime type
$var = FSFile::getPropsFromPath(temppath and extension)

Case1:When i upload images from google image search for example - http://www.hollywoodreporter.com/sites/default/files/2011/05/googlelogoa_a_l.jpg

'''$var contains the right MIME Type'''

Case2:When i upload a pic from wikipedia
http://commons.wikimedia.org/wiki/File:Gyps_rueppellii_-Nairobi_National_Park,_Kenya-8-4c.jpg

$var contains *WRONG* MIME Type.It contains MIME type of text/html(The same error comes when we try to upload a html page)which is blacklisted by default.

I think it is interpreting these kinds of images as HTML pages

Thanks for checking into that. It looks like I reported this bug before I understood the difference between a file page and the actual file. I marked the bug as invalid.

Gilles raised the priority of this task from Medium to Unbreak Now!.Dec 4 2014, 10:27 AM
Gilles added a project: Multimedia.
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to Medium.Dec 4 2014, 11:21 AM