r44987 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44986‎ | r44987 | r44988 >
Date:23:00, 23 December 2008
Author:mrzman
Status:resolved (Comments)
Tags:
Comment:
(bug 16772) Special:Upload now correctly rejects files with spaces in the file extension (e.g. Foo. jpg) by normalizing the title before checking the extension.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUpload.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUpload.php
@@ -399,15 +399,20 @@
400400 $basename = $this->mSrcName;
401401 }
402402 $filtered = wfStripIllegalFilenameChars( $basename );
403 -
 403+
 404+ $nt = Title::makeTitleSafe( NS_FILE, $filtered );
 405+ if( is_null( $nt ) ) {
 406+ $resultDetails = array( 'filtered' => $filtered );
 407+ return self::ILLEGAL_FILENAME;
 408+ }
404409 /**
405410 * We'll want to blacklist against *any* 'extension', and use
406411 * only the final one for the whitelist.
407412 */
408 - list( $partname, $ext ) = $this->splitExtensions( $filtered );
 413+ list( $partname, $ext ) = $this->splitExtensions( $nt->getDBkey() );
409414
410415 if( count( $ext ) ) {
411 - $finalExt = trim( $ext[count( $ext ) - 1] );
 416+ $finalExt = $ext[count( $ext ) - 1];
412417 } else {
413418 $finalExt = '';
414419 }
@@ -423,11 +428,6 @@
424429 return self::MIN_LENGHT_PARTNAME;
425430 }
426431
427 - $nt = Title::makeTitleSafe( NS_FILE, $filtered );
428 - if( is_null( $nt ) ) {
429 - $resultDetails = array( 'filtered' => $filtered );
430 - return self::ILLEGAL_FILENAME;
431 - }
432432 $this->mLocalFile = wfLocalFile( $nt );
433433 $this->mDestName = $this->mLocalFile->getName();
434434
Index: trunk/phase3/RELEASE-NOTES
@@ -451,6 +451,8 @@
452452 redirectedfrom, historywarning and difference messages now use Wiki text
453453 rather than raw HTML markup
454454 * (bug 13835) Fix rendering of {{filepath:Wiki.png|nowiki}}
 455+* (bug 16772) Special:Upload now correctly rejects files with spaces in the
 456+ file extension (e.g. Foo. jpg).
455457
456458 === API changes in 1.14 ===
457459

Follow-up revisions

RevisionCommit summaryAuthorDate
r44989Follow-up to r44987 -- use the Title-filtered version for the rest of our fil...brion23:19, 23 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   23:22, 23 December 2008

Made a tiny tweak to set $filtered to the dbkey value since it's used later on.

Status & tagging log