(bug 23464) File: prefixes are now chopped off during uploading.
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sun, 15 May 2011 12:51:52 +0000 (12:51 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sun, 15 May 2011 12:51:52 +0000 (12:51 +0000)
RELEASE-NOTES-1.19
includes/upload/UploadBase.php

index 4b9012a..63fe431 100644 (file)
@@ -51,6 +51,7 @@ used in Tiff files.
   make the width be the max SVG size, not the natrual width of the SVG.
 * (bug 1780) Uploading files with non-ascii characters are now forbidden on
   Windows.
+* (bug 23464) File: prefixes are now chopped off during uploading.
 
 === API changes in 1.19 ===
 * (bug 27790) add query type for querymodules to action=paraminfo
index 2d351ac..8efe94d 100644 (file)
@@ -599,13 +599,23 @@ abstract class UploadBase {
                if ( $this->mTitle !== false ) {
                        return $this->mTitle;
                }
+               
+               /* Assume that if a user specified File:Something.jpg, this is an error
+                * and that the namespace prefix needs to be stripped of.
+                */
+               $title = Title::newFromText( $this->mDesiredDestName );
+               if ( $title->getNamespace() == NS_FILE ) {
+                       $this->mFilteredName = $title->getDBkey();
+               } else {
+                       $this->mFilteredName = $this->mDesiredDestName;
+               }
 
                /**
                 * Chop off any directories in the given filename. Then
                 * filter out illegal characters, and try to make a legible name
                 * out of it. We'll strip some silently that Title would die on.
                 */
-               $this->mFilteredName = wfStripIllegalFilenameChars( $this->mDesiredDestName );
+               $this->mFilteredName = wfStripIllegalFilenameChars( $this->mFilteredName );
                /* Normalize to title form before we do any further processing */
                $nt = Title::makeTitleSafe( NS_FILE, $this->mFilteredName );
                if( is_null( $nt ) ) {