Adhere to mediawiki file name restrictions when changing title
Closed, ResolvedPublic

Description

Motivation
When a file is imported to Commons, users may change its name, e.g. because the current file name already exists on Commons. This means that our extension allows setting file names, and should adhere to all file naming standards of mediawiki.

Task
Apply all file naming standards of mediawiki, when users want to change the title of an imported file in the file importer extension, e.g. through the special page.
This means:

  • apply existing file name rules
  • handle name space prefixes gracefully
  • handle file endings gracefully. Ideally, allow renamings from jpg to JPG or jpeg, but don't allow a file type switch.
Restricted Application added a project: User-Addshore. · View Herald TranscriptApr 20 2017, 8:38 PM
Lea_WMDE updated the task description. (Show Details)Apr 20 2017, 8:43 PM

handle file endings gracefully. Ideally, allow renamings from jpg to JPG or jpeg, but don't allow a file type switch.

Does it make sense to somewhat separate filename and the .end part (from a tech/wiki perspective)? E.g. for them having separate edit buttons for "change name" and "adjust ending" (what is this actually called?)

Some approaches to this:

  • Just allow editing the full name, including the .end suffix (I think pre-2000 windows versions did so. Rationale: It is just all a name.)
  • Hide the .end suffix and only show on request (Windows versions does so. Rationale: File endings are a property of the technical file itself. The part before is lable/metadata)
  • Allow editing including the .end suffix AND mark the non-suffix part on edit (this discouraging editing the end a bit) (Nautilus does so):
  • Not sure about mac – technically they don’t need it (neither does Linux) as far as I am concerned – so do they have many files without .end?

Some of this will have been done in https://gerrit.wikimedia.org/r/#/c/348722/ which is merged
I need to review this ticket and see what still needs to be done here.

Addshore moved this task from Backlog to In Progress on the User-Addshore board.Apr 24 2017, 3:52 PM
Addshore moved this task from Proposed to Sprint ready on the WMDE-QWERTY-Team-Board board.

Excess file extensions

So I checked with uploading and names such as "http://mwfileimport.wmflabs.org/wiki/index.php/File:Bluesq.png.png.gif.bmp.jpg.jpg.png" are allowed,.
This is also able to happen through fileimporter

Excess namespaces

Currently fileimporter breaks when you try to specify a title such as File:File:File:FileFoo.png

When uploading to a title such as this using Special:Upload you see the message:

Filename has been changed to "File-File-FileFoo.png".

FileImporter should have the same behaviour here.

Subpages

Currently if you try to import a file to File:Hawk_127_touchdown_(8523142767)_(4).jpg/Foo_Bar_Baz.png it will end up at "File:Foo bar baz.jpg" which is odd and needs investigating.

It looks like we need to run the checks that are currently in UploadBase::checkWarnings. Right now we only run the checks in UploadBase::performChecks

Change 352612 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/core@master] Refactor UploadBase::checkWarnings into smaller methods

https://gerrit.wikimedia.org/r/352612

Change 363007 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/FileImporter@master] Make sure planned title has an extension.

https://gerrit.wikimedia.org/r/363007

Change 363008 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/FileImporter@master] Change of file extension case is allowed

https://gerrit.wikimedia.org/r/363008

Change 363009 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/FileImporter@master] Check planned titles against wfStripIllegalFilenameChars

https://gerrit.wikimedia.org/r/363009

Change 363007 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Make sure planned & source title has an extension.

https://gerrit.wikimedia.org/r/363007

Change 363008 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Change of file extension case is allowed

https://gerrit.wikimedia.org/r/363008

Change 363009 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Check planned titles against wfStripIllegalFilenameChars

https://gerrit.wikimedia.org/r/363009

Change 363029 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/FileImporter@master] Show file extension in preview & edit pages

https://gerrit.wikimedia.org/r/363029

Addshore added a comment.EditedJul 4 2017, 1:19 PM

I have also just found UploadBase::getTitle which has some checks that FileImporter should also do.

Change 363183 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/FileImporter@master] ImportPlanValidator, perform checks in UploadBase::getTitle

https://gerrit.wikimedia.org/r/363183

Addshore added a subscriber: daniel.Jul 4 2017, 3:40 PM

@daniel if you can think of any testcases for edge case titles please let me know so I can add tests for them!

Change 363029 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Show file extension in preview & edit pages

https://gerrit.wikimedia.org/r/363029

Change 363183 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] ImportPlanValidator, perform checks in UploadBase::getTitle

https://gerrit.wikimedia.org/r/363183

Change 352612 merged by jenkins-bot:
[mediawiki/core@master] Refactor UploadBase::checkWarnings into smaller methods

https://gerrit.wikimedia.org/r/352612

Change 364470 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/FileImporter@master] Use TitleParser in ImportPlanValidator & check

https://gerrit.wikimedia.org/r/364470

Change 364470 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Use TitleParser in ImportPlanValidator & check

https://gerrit.wikimedia.org/r/364470

One patch is still open: https://gerrit.wikimedia.org/r/#/c/364490
Once this is merged, we can do another demo and check if we find any more edge cases or if we can finally close this.

Addshore moved this task from In Progress to Done on the User-Addshore board.
Addshore closed this task as Resolved.Aug 31 2017, 9:15 AM