From 2ff5dde9ab5e6507cd13cfdef8aaa8e695ff4d1e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2004 10:43:43 +0000 Subject: [PATCH] A couple of further changes: * 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) --- includes/SpecialUpload.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 5a01331b4c..5da613b17e 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -127,6 +127,13 @@ class UploadForm { 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('
  • '.wfMsg( 'emptyfile' ).'
  • '); + } + /** * When using detailed copyright, if user filled field, assume he * confirmed the upload @@ -142,15 +149,10 @@ class UploadForm { /** User need to confirm his upload */ if( !$this->mUploadAffirm ) { - $this->mainUploadForm( WfMsg( 'noaffirmation' ) ); + $this->mainUploadForm( wfMsg( 'noaffirmation' ) ); return; } - if ( $this->mOname == '' && !isset($this->mUploadSaveName) ) { - // no filename given! - return $this->uploadError('
  • '.wfMsg( 'emptyfile' ).'
  • '); - } - # Chop off any directories in the given filename $basename = basename( $this->mOname ); @@ -171,7 +173,7 @@ class UploadForm { * 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 ) ) ); -- 2.20.1