(bug 1780) Uploading files with non-ascii characters are now forbidden on Windows...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sun, 15 May 2011 12:35:50 +0000 (12:35 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sun, 15 May 2011 12:35:50 +0000 (12:35 +0000)
RELEASE-NOTES-1.19
includes/api/ApiUpload.php
includes/specials/SpecialUpload.php
includes/upload/UploadBase.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index ab134fa..4b9012a 100644 (file)
@@ -49,6 +49,8 @@ used in Tiff files.
 * (bug 28287) The "your changes" box for edit conflicts is now read-only.
 * (bug 28940) When making a thumb of an SVG, and only specifying the height
   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.
 
 === API changes in 1.19 ===
 * (bug 27790) add query type for querymodules to action=paraminfo
index f21408c..a84f15c 100644 (file)
@@ -294,6 +294,9 @@ class ApiUpload extends ApiBase {
                        case UploadBase::FILETYPE_MISSING:
                                $this->dieRecoverableError( 'filetype-missing', 'filename' );
                                break;
+                       case UploadBase::WINDOWS_NONASCII_FILENAME:
+                               $this->dieRecoverableError( 'windows-nonascii-filename', 'filename' );
+                               break;
                        
                        // Unrecoverable errors
                        case UploadBase::EMPTY_FILE:
index 8286340..32b8ab6 100644 (file)
@@ -583,6 +583,10 @@ class SpecialUpload extends SpecialPage {
                                $this->showRecoverableUploadError( wfMsgExt( 'filetype-missing',
                                        'parseinline' ) );
                                break;
+                       case UploadBase::WINDOWS_NONASCII_FILENAME:
+                               $this->showRecoverableUploadError( wfMsgExt( 'windows-nonascii-filename',
+                                       'parseinline' ) );
+                               break;
 
                        /** Statuses that require reuploading **/
                        case UploadBase::EMPTY_FILE:
index 0741326..2d351ac 100644 (file)
@@ -36,6 +36,7 @@ abstract class UploadBase {
        const UPLOAD_VERIFICATION_ERROR = 11;
        const HOOK_ABORTED = 11;
        const FILE_TOO_LARGE = 12;
+       const WINDOWS_NONASCII_FILENAME = 13;
 
        const SESSION_VERSION = 2;
        const SESSION_KEYNAME = 'wsUploadData';
@@ -54,6 +55,7 @@ abstract class UploadBase {
                                                                self::OVERWRITE_EXISTING_FILE => 'overwrite',
                                                                self::VERIFICATION_ERROR => 'verification-error',
                                                                self::HOOK_ABORTED =>  'hookaborted',
+                                                               self::WINDOWS_NONASCII_FILENAME => 'windows-nonascii-filename',
                );
                if( isset( $code_to_status[$error] ) ) {
                        return $code_to_status[$error];
@@ -658,6 +660,12 @@ abstract class UploadBase {
                        $this->mTitleError = self::FILETYPE_BADTYPE;
                        return $this->mTitle = null;
                }
+               
+               // Windows may be broken with special characters, see bug XXX
+               if ( wfIsWindows() && !preg_match( '/^[\x0-\x7f]*$/', $nt->getText() ) ) {
+                       $this->mTitleError = self::WINDOWS_NONASCII_FILENAME;
+                       return $this->mTitle = null;
+               }
 
                # If there was more than one "extension", reassemble the base
                # filename to prevent bogus complaints about length
index a9d2ad2..01c9c7f 100644 (file)
@@ -2163,6 +2163,7 @@ If you still want to upload your file, please go back and use a new name.
 'file-exists-duplicate'       => 'This file is a duplicate of the following {{PLURAL:$1|file|files}}:',
 'file-deleted-duplicate'      => "A file identical to this file ([[:$1]]) has previously been deleted.
 You should check that file's deletion history before proceeding to re-upload it.",
+'windows-nonascii-filename'   => 'The server does not support filenames with special characters.',
 'uploadwarning'               => 'Upload warning',
 'uploadwarning-text'          => 'Please modify the file description below and try again.',
 'savefile'                    => 'Save file',
index 46e0d39..80b0d17 100644 (file)
@@ -1282,6 +1282,7 @@ $wgMessageStructure = array(
                'large-file',
                'largefileserver',
                'emptyfile',
+               'windows-nonascii-filename',
                'fileexists',
                'filepageexists',
                'fileexists-extension',