period ('.') is a valid character in a file name (foo.bar.jpg is not the same as foo.jpg)
Closed, ResolvedPublic

Description

Author: brianna.laugher

Description:
Hi,

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.


Version: unspecified
Severity: minor

bzimport added a project: MediaWiki-Uploading.Via ConduitNov 21 2014, 10:07 PM
bzimport added a subscriber: wikibugs-l.
bzimport set Reference to bz13143.
bzimport created this task.Via LegacyFeb 25 2008, 6:21 AM
Huji added a comment.Via ConduitFeb 25 2008, 9:26 AM

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.

werdna added a comment.Via ConduitFeb 25 2008, 9:34 AM

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.

Huji added a comment.Via ConduitFeb 25 2008, 9:36 AM

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).

werdna added a comment.Via ConduitFeb 25 2008, 10:11 AM

Fixed in r31246.

Gilles added a project: Multimedia.Via WebDec 4 2014, 10:49 AM
Gilles moved this task to Closed on the Multimedia workboard.

Add Comment

Column Prototype
This is a very early prototype of a persistent column. It is not expected to work yet, and leaving it open will activate other new features which will break things. Press "\" (backslash) on your keyboard to close it now.