Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1273,6 +1273,7 @@ |
1274 | 1274 | 'ignorewarnings', |
1275 | 1275 | 'minlength1', |
1276 | 1276 | 'illegalfilename', |
| 1277 | + 'filename-toolong', |
1277 | 1278 | 'badfilename', |
1278 | 1279 | 'filetype-mime-mismatch', |
1279 | 1280 | 'filetype-badmime', |
Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | const HOOK_ABORTED = 11; |
39 | 39 | const FILE_TOO_LARGE = 12; |
40 | 40 | const WINDOWS_NONASCII_FILENAME = 13; |
| 41 | + const FILENAME_TOO_LONG = 14; |
41 | 42 | |
42 | 43 | public function getVerificationErrorCode( $error ) { |
43 | 44 | $code_to_status = array(self::EMPTY_FILE => 'empty-file', |
— | — | @@ -49,6 +50,7 @@ |
50 | 51 | self::VERIFICATION_ERROR => 'verification-error', |
51 | 52 | self::HOOK_ABORTED => 'hookaborted', |
52 | 53 | self::WINDOWS_NONASCII_FILENAME => 'windows-nonascii-filename', |
| 54 | + self::FILENAME_TOO_LONG => 'filename-toolong', |
53 | 55 | ); |
54 | 56 | if( isset( $code_to_status[$error] ) ) { |
55 | 57 | return $code_to_status[$error]; |
— | — | @@ -617,6 +619,13 @@ |
618 | 620 | $this->mFilteredName = $this->mDesiredDestName; |
619 | 621 | } |
620 | 622 | |
| 623 | + # oi_archive_name is max 255 bytes, which include a timestamp and an |
| 624 | + # exclamation mark, so restrict file name to 240 bytes. |
| 625 | + if ( strlen( $this->mFilteredName ) > 240 ) { |
| 626 | + $this->mTitleError = self::FILENAME_TOO_LONG; |
| 627 | + return $this->mTitle = null; |
| 628 | + } |
| 629 | + |
621 | 630 | /** |
622 | 631 | * Chop off any directories in the given filename. Then |
623 | 632 | * filter out illegal characters, and try to make a legible name |
— | — | @@ -631,13 +640,7 @@ |
632 | 641 | } |
633 | 642 | $this->mFilteredName = $nt->getDBkey(); |
634 | 643 | |
635 | | - # oi_archive_name is max 255 bytes, which include a timestamp and an |
636 | | - # exclamation mark, so restrict file name to 240 bytes. Return |
637 | | - # ILLEGAL_FILENAME, just like would have happened for >255 bytes |
638 | | - if ( strlen( $this->mFilteredName ) > 240 ) { |
639 | | - $this->mTitleError = self::ILLEGAL_FILENAME; |
640 | | - return $this->mTitle = null; |
641 | | - } |
| 644 | + |
642 | 645 | |
643 | 646 | /** |
644 | 647 | * We'll want to blacklist against *any* 'extension', and use |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -350,6 +350,9 @@ |
351 | 351 | $this->dieRecoverableError( 'illegal-filename', 'filename', |
352 | 352 | array( 'filename' => $verification['filtered'] ) ); |
353 | 353 | break; |
| 354 | + case UploadBase::FILENAME_TOO_LONG: |
| 355 | + $this->dieRecoverableError( 'filename-toolong', 'filename' ); |
| 356 | + break; |
354 | 357 | case UploadBase::FILETYPE_MISSING: |
355 | 358 | $this->dieRecoverableError( 'filetype-missing', 'filename' ); |
356 | 359 | break; |
Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -558,6 +558,9 @@ |
559 | 559 | $this->showRecoverableUploadError( wfMsgExt( 'illegalfilename', |
560 | 560 | 'parseinline', $details['filtered'] ) ); |
561 | 561 | break; |
| 562 | + case UploadBase::FILENAME_TOO_LONG: |
| 563 | + $this->showRecoverableUploadError( wfMsgHtml( 'filename-toolong' ) ); |
| 564 | + break; |
562 | 565 | case UploadBase::FILETYPE_MISSING: |
563 | 566 | $this->showRecoverableUploadError( wfMsgExt( 'filetype-missing', |
564 | 567 | 'parseinline' ) ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2119,6 +2119,7 @@ |
2120 | 2120 | 'minlength1' => 'File names must be at least one letter.', |
2121 | 2121 | 'illegalfilename' => 'The filename "$1" contains characters that are not allowed in page titles. |
2122 | 2122 | Please rename the file and try uploading it again.', |
| 2123 | +'filename-toolong' => 'File names may not be longer than 240 bytes.', |
2123 | 2124 | 'badfilename' => 'File name has been changed to "$1".', |
2124 | 2125 | 'filetype-mime-mismatch' => 'File extension ".$1" does not match the detected MIME type of the file ($2).', |
2125 | 2126 | 'filetype-badmime' => 'Files of the MIME type "$1" are not allowed to be uploaded.', |