* Move the empty check up to the top, so the message isn't misleading
* Strip colons out of the names, as this sometimes has odd effects and is probably not so allowed on Windows.
Forgot to mention, last commit included some fragments from the patch by Benjamin Jemlich (http://bugzilla.wikipedia.org/attachment.cgi?id=46)
global $wgUploadDirectory;
global $wgUseCopyrightUpload, $wgCheckCopyrightUpload;
global $wgUploadDirectory;
global $wgUseCopyrightUpload, $wgCheckCopyrightUpload;
+ /**
+ * If there was no filename or a zero size given, give up quick.
+ */
+ if( ( trim( $this->mOname ) == '' ) || empty( $this->mUploadSize ) ) {
+ return $this->mainUploadForm('<li>'.wfMsg( 'emptyfile' ).'</li>');
+ }
+
/**
* When using detailed copyright, if user filled field, assume he
* confirmed the upload
/**
* When using detailed copyright, if user filled field, assume he
* confirmed the upload
/** User need to confirm his upload */
if( !$this->mUploadAffirm ) {
/** User need to confirm his upload */
if( !$this->mUploadAffirm ) {
- $this->mainUploadForm( WfMsg( 'noaffirmation' ) );
+ $this->mainUploadForm( wfMsg( 'noaffirmation' ) );
- if ( $this->mOname == '' && !isset($this->mUploadSaveName) ) {
- // no filename given!
- return $this->uploadError('<li>'.wfMsg( 'emptyfile' ).'</li>');
- }
-
# Chop off any directories in the given filename
$basename = basename( $this->mOname );
# Chop off any directories in the given filename
$basename = basename( $this->mOname );
* Filter out illegal characters, and try to make a legible name
* out of it. We'll strip some silently that Title would die on.
*/
* Filter out illegal characters, and try to make a legible name
* out of it. We'll strip some silently that Title would die on.
*/
- $filtered = preg_replace ( "/[^".Title::legalChars()."]/", '-', $basename );
+ $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $basename );
$nt = Title::newFromText( $filtered );
if( is_null( $nt ) ) {
return $this->uploadError( wfMsg( 'illegalfilename', htmlspecialchars( $filtered ) ) );
$nt = Title::newFromText( $filtered );
if( is_null( $nt ) ) {
return $this->uploadError( wfMsg( 'illegalfilename', htmlspecialchars( $filtered ) ) );