http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88165
Revision: 88165
Author: btongminh
Date: 2011-05-15 12:35:50 +0000 (Sun, 15 May 2011)
Log Message:
-----------
(bug 1780) Uploading files with non-ascii characters are now forbidden on
Windows. PHP on Windows does not reliably support non-ascii characters to
forbid them all. Theoretically we could detect the filesystem locale and iconv
the filename, but that is just too much hassle. Added message
'windows-nonascii-filename'.
Modified Paths:
--------------
trunk/phase3/RELEASE-NOTES-1.19
trunk/phase3/includes/api/ApiUpload.php
trunk/phase3/includes/specials/SpecialUpload.php
trunk/phase3/includes/upload/UploadBase.php
trunk/phase3/languages/messages/MessagesEn.php
trunk/phase3/maintenance/language/messages.inc
Modified: trunk/phase3/RELEASE-NOTES-1.19
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.19 2011-05-15 12:34:00 UTC (rev 88164)
+++ trunk/phase3/RELEASE-NOTES-1.19 2011-05-15 12:35:50 UTC (rev 88165)
@@ -49,6 +49,8 @@
* (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
Modified: trunk/phase3/includes/api/ApiUpload.php
===================================================================
--- trunk/phase3/includes/api/ApiUpload.php 2011-05-15 12:34:00 UTC (rev
88164)
+++ trunk/phase3/includes/api/ApiUpload.php 2011-05-15 12:35:50 UTC (rev
88165)
@@ -294,6 +294,9 @@
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:
Modified: trunk/phase3/includes/specials/SpecialUpload.php
===================================================================
--- trunk/phase3/includes/specials/SpecialUpload.php 2011-05-15 12:34:00 UTC
(rev 88164)
+++ trunk/phase3/includes/specials/SpecialUpload.php 2011-05-15 12:35:50 UTC
(rev 88165)
@@ -583,6 +583,10 @@
$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:
Modified: trunk/phase3/includes/upload/UploadBase.php
===================================================================
--- trunk/phase3/includes/upload/UploadBase.php 2011-05-15 12:34:00 UTC (rev
88164)
+++ trunk/phase3/includes/upload/UploadBase.php 2011-05-15 12:35:50 UTC (rev
88165)
@@ -36,6 +36,7 @@
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 @@
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 @@
$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
Modified: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php 2011-05-15 12:34:00 UTC
(rev 88164)
+++ trunk/phase3/languages/messages/MessagesEn.php 2011-05-15 12:35:50 UTC
(rev 88165)
@@ -2163,6 +2163,7 @@
'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',
Modified: trunk/phase3/maintenance/language/messages.inc
===================================================================
--- trunk/phase3/maintenance/language/messages.inc 2011-05-15 12:34:00 UTC
(rev 88164)
+++ trunk/phase3/maintenance/language/messages.inc 2011-05-15 12:35:50 UTC
(rev 88165)
@@ -1282,6 +1282,7 @@
'large-file',
'largefileserver',
'emptyfile',
+ 'windows-nonascii-filename',
'fileexists',
'filepageexists',
'fileexists-extension',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs