Page MenuHomePhabricator

Upload fails and unable to move existing .dem files without extension: "Key 'something.' is not in a proper format"
Open, MediumPublic

Description

Author: msn

Description:
Since updating to 1.17rc1 today, file uploads of types for which there is not a particular mime-type (in my case, ".dem" files, which are demo files from Valve's Source Engine games). Image uploads work fine.

Additionally, attempting to move already-uploaded .dem files, without changing the .dem extension, cause the error "The new file extension does not match its type" to appear (and the file doesn't move).

Output:

key 'fw9re1ay7wwdqf7p4c4eiyupmxwdezn.' is not in a proper format

Backtrace:
#0 /home/pwiki/www/w/includes/upload/UploadBase.php(634): UploadStash->stashFile('/tmp/phpNsK1a1', Array, NULL)
#1 /home/pwiki/www/w/includes/upload/UploadBase.php(646): UploadBase->stashSessionFile(NULL)
#2 /home/pwiki/www/w/includes/specials/SpecialUpload.php(367): UploadBase->stashSession()
#3 /home/pwiki/www/w/includes/specials/SpecialUpload.php(461): SpecialUpload->showUploadWarning(Array)
#4 /home/pwiki/www/w/includes/specials/SpecialUpload.php(192): SpecialUpload->processUpload()
#5 /home/pwiki/www/w/includes/SpecialPage.php(578): SpecialUpload->execute(NULL)
#6 /home/pwiki/www/w/includes/Wiki.php(251): SpecialPage::executePath(Object(Title))
#7 /home/pwiki/www/w/includes/Wiki.php(63): MediaWiki->handleSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest))
#8 /home/pwiki/www/w/index.php(114): MediaWiki->performRequestForTitle(Object(Title), NULL, Object(OutputPage), Object(User), Object(WebRequest))
#9 {main}

Attached is the file that I am attempting to upload.


Version: 1.20.x
Severity: normal

Details

Reference
bz29408

Event Timeline

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

msn wrote:

File is too large to attach, so I uploaded it there instead:
http://upload.gaiatools.com/files/p2escape_1_0.dem

Bryan.TongMinh wrote:

Related to bug 26367, presumably happens when the file is not recognized by MimeMagic.

Assigning to Neil.

msn wrote:

I tried adding the line:

application/octet-stream dem

to includes/MimeMagic.php, but it didn't change anything :(

Bryan.TongMinh wrote:

Test case

Test that should pass if this bug is fixed.

Attached:

Bryan.TongMinh wrote:

Fixed in r90340

msn wrote:

Thanks! However, this does not fix the second half of the problem:
Attempting to move already-uploaded .dem files, without changing the .dem extension, causes the error "The new file extension does not match its type" to appear (and the file doesn't move).

Thehelpfulonewiki wrote:

Reassigning to wikibugs-l per bug 37789

msn: Is moving already-uploaded .dem files still a problem in a recent MediaWiki version? If so, what are exact steps to reproduce?

msn: Is moving already-uploaded .dem files still a problem in a recent
MediaWiki version? If so, what are exact steps to reproduce?

msn wrote:

This is still present in MediaWiki 1.20.3.

Steps to reproduce:

  • Upload the .dem file linked above
  • Try to rename it to something else (keeping the .dem extension)

Error obtained:
"You do not have permission to move this page, for the following reason:

The new file extension does not match its type"

Perhaps interestingly, the file page - http://theportalwiki.com/wiki/File:Portal_2_-_Chapter_4_-_Chamber_21_%28Escape%29.dem - says "MIME type: application/vnd.ms-excel.sheet.binary.macroenabled.12" which is definitely inaccurate. I suspect that, when moving, it checks if the new filename's extension corresponds to the MIME type of the file, which MediaWiki incorrectly assigned to begin with.