Last modified: 2008-02-25 10:11:24 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 13143 - period ('.') is a valid character in a file name ( is not the same as foo.jpg)
period ('.') is a valid character in a file name ( is not the same...
Product: MediaWiki
Classification: Unclassified
Uploading (Other open bugs)
All All
: Normal minor (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2008-02-25 06:21 UTC by brianna.laugher
Modified: 2008-02-25 10:11 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description brianna.laugher 2008-02-25 06:21:33 UTC

A user at Commons reported getting an inappropriate warning:

When I do a trial upload of one image, I get an error "a file with a similar name already exists, choose another  filename". Unfortunately the file that already exists is "drosera.jpg" (not my picture) and that blocks my "drosera.spatulata.flower.x16.jpg" and it will block all other Drosera images too.

I believe this is [[MediaWiki:fileexists-extension]] was introduced in r25481.

I believe it is caused because of this previous line in SpecialUpload.php:

                   list( $partname, $rawExtension ) = explode( '.', $file->getName(), 2 );

So in this case I think we have $partname = 'drosera', $rawExtension = 'spatulata'.

f ( $rawExtension != $file->getExtension() ) {
474 	                         $nt_lc = Title::newFromText( $partname . '.' . strtolower( $ext ) ); 	                         // We're not using the normalized form of the extension.
475 	  	                         // Normal form is lowercase, using most common of alternate
476 	  	                         // extensions (eg 'jpg' rather than 'JPEG').
477 	  	                         //
478 	  	                         // Check for another file using the normalized form...
479 	  	                         $nt_lc = Title::newFromText( $partname . '.' . $file->getExtension() );

then since 'spatulata' != 'jpg', the new title ends up being 'drosera.jpg'. Hence the inappropriate error.

If '.' was not allowed in image titles that would work fine.

To fix it I suppose you could either do a regex string split thing, or else, do the explode and then join all but the last one back up again to form $partname.
Comment 1 Huji 2008-02-25 09:26:13 UTC
Well the warning message sort of answers your question. It says "a file with a SIMILAR name already exists, choose another  filename". If you press the ignore button, the file will be saves, with the exact name you provided, and it DOESN'T overwrite the other file (which is a "similar" but not identical) name.

Please let us know if you've got your answer here.
Comment 2 Andrew Garrett 2008-02-25 09:34:01 UTC
No, that's not the issue, Huji. The issue is that exploding based on the occurrence of '.' in the file name is the wrong way to find the extension. We should be going BACK from the end, rather than FORWARD from the beginning. I'm working on a patch for this now.
Comment 3 Huji 2008-02-25 09:36:34 UTC
Oops! Sorry for my misunderstanding. Hopefully, the fix with be easy to achieve since PHP has lots of string functions which go backward in a string (although RegExp is an option too).
Comment 4 Andrew Garrett 2008-02-25 10:11:24 UTC
Fixed in r31246.

Note You need to log in before you can comment on or make changes to this bug.