Page MenuHomePhabricator

MW upload API file auto-extention voodoo
Closed, InvalidPublic

Description

I suspect this auto-extension voodoo has been added to MW recently. — jayvdb, IRC

Extension is considered to have a form of period and some alphanumeric characters. Each name within File: namespace should end with an extension corresponding to its file metadata type. It's possible to create a filepage with any number of pseudo extentions (File:MP_sounds.firstext.secondext.png).

When trying to upload a file with API (I use script/upload.py):

  1. If filename ends with a period (.), it raises APIError: filetype-missing: The file is missing an extension.
  2. If filename does not have an extension, API appends file's extension from its metadata.
  3. If filename has 1 or more extensions and the last one corresponds to metadata, filename is not going to be changed.
  4. If filename has 1 or more extensions and the last one does not correspond to metadata, it raises APIError: verification-error: This file did not pass file verification.

Some behaviours should be changed:

  1. do not remove period, do same as 2 — to be discussed. File:MP_sounds_renamed..png is possible. It may be useful to upload files with pathetic ellipsis.
  2. correct
  3. correct
  4. do same as 2 — to be discussed. In general it should do 2 but some “intellectual” cases may be added: say, if file's metadata type is png, filename is MP_sounds_great.jpg and MP_sounds_great.png does not exist, it may shave .jpg and append actual extension.

Event Timeline

murfel created this task.Jan 2 2015, 6:38 PM
murfel raised the priority of this task from to Needs Triage.
murfel updated the task description. (Show Details)
murfel added a project: MediaWiki-API.
murfel added subscribers: murfel, jayvdb.
Anomie set Security to None.
Anomie added a subscriber: Anomie.Jan 3 2015, 11:24 PM

This has to do with the underlying MediaWiki code, not the API.

If filename has 1 or more extensions and the last one does not correspond to metadata, API shaves all the extensions and appends file's extension from its metadata.

Can't reproduce. When I try this, I get a filetype-mime-mismatch verification error.

murfel updated the task description. (Show Details)Jan 4 2015, 5:07 AM
murfel closed this task as Invalid.Jan 4 2015, 5:44 AM
murfel claimed this task.

I can't reproduce it too. Sorry, I got it wrong.

Now I see that these API errors are the soft steps to make each file to have its extension and each user to know this.

murfel removed murfel as the assignee of this task.Jan 4 2015, 5:46 AM