$this->dieRecoverableError( 'illegal-filename', 'filename',
array( 'filename' => $verification['filtered'] ) );
break;
+ case UploadBase::FILENAME_TOO_LONG:
+ $this->dieRecoverableError( 'filename-toolong', 'filename' );
+ break;
case UploadBase::FILETYPE_MISSING:
$this->dieRecoverableError( 'filetype-missing', 'filename' );
break;
$this->showRecoverableUploadError( wfMsgExt( 'illegalfilename',
'parseinline', $details['filtered'] ) );
break;
+ case UploadBase::FILENAME_TOO_LONG:
+ $this->showRecoverableUploadError( wfMsgHtml( 'filename-toolong' ) );
+ break;
case UploadBase::FILETYPE_MISSING:
$this->showRecoverableUploadError( wfMsgExt( 'filetype-missing',
'parseinline' ) );
const HOOK_ABORTED = 11;
const FILE_TOO_LARGE = 12;
const WINDOWS_NONASCII_FILENAME = 13;
+ const FILENAME_TOO_LONG = 14;
public function getVerificationErrorCode( $error ) {
$code_to_status = array(self::EMPTY_FILE => 'empty-file',
self::VERIFICATION_ERROR => 'verification-error',
self::HOOK_ABORTED => 'hookaborted',
self::WINDOWS_NONASCII_FILENAME => 'windows-nonascii-filename',
+ self::FILENAME_TOO_LONG => 'filename-toolong',
);
if( isset( $code_to_status[$error] ) ) {
return $code_to_status[$error];
$this->mFilteredName = $this->mDesiredDestName;
}
+ # oi_archive_name is max 255 bytes, which include a timestamp and an
+ # exclamation mark, so restrict file name to 240 bytes.
+ if ( strlen( $this->mFilteredName ) > 240 ) {
+ $this->mTitleError = self::FILENAME_TOO_LONG;
+ return $this->mTitle = null;
+ }
+
/**
* Chop off any directories in the given filename. Then
* filter out illegal characters, and try to make a legible name
}
$this->mFilteredName = $nt->getDBkey();
- # oi_archive_name is max 255 bytes, which include a timestamp and an
- # exclamation mark, so restrict file name to 240 bytes. Return
- # ILLEGAL_FILENAME, just like would have happened for >255 bytes
- if ( strlen( $this->mFilteredName ) > 240 ) {
- $this->mTitleError = self::ILLEGAL_FILENAME;
- return $this->mTitle = null;
- }
+
/**
* We'll want to blacklist against *any* 'extension', and use
'minlength1' => 'File names must be at least one letter.',
'illegalfilename' => 'The filename "$1" contains characters that are not allowed in page titles.
Please rename the file and try uploading it again.',
+'filename-toolong' => 'File names may not be longer than 240 bytes.',
'badfilename' => 'File name has been changed to "$1".',
'filetype-mime-mismatch' => 'File extension ".$1" does not match the detected MIME type of the file ($2).',
'filetype-badmime' => 'Files of the MIME type "$1" are not allowed to be uploaded.',