From 723db87d9d1f9000d04146d6db1ccc92b4677af8 Mon Sep 17 00:00:00 2001 From: Hashar Date: Fri, 17 May 2019 14:42:21 +0000 Subject: [PATCH] Revert "Always validate uploads over api" The verification is broken with chunken uploads and ultimately cause large files to no more be uploadable. This reverts commit 38ec6d8a344d4eda0307dd3a72653dd2171305d6. Bug: T223448 Change-Id: If414a8f751a3e1488a2ab099abd8b598c973c1f4 --- includes/api/ApiUpload.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index f0d271cb04..fc41e4ea6a 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -74,8 +74,20 @@ class ApiUpload extends ApiBase { } // Check if the uploaded file is sane - wfDebug( __METHOD__ . " about to verify\n" ); - $this->verifyUpload(); + if ( $this->mParams['chunk'] ) { + $maxSize = UploadBase::getMaxUploadSize(); + if ( $this->mParams['filesize'] > $maxSize ) { + $this->dieWithError( 'file-too-large' ); + } + if ( !$this->mUpload->getTitle() ) { + $this->dieWithError( 'illegal-filename' ); + } + } elseif ( $this->mParams['async'] && $this->mParams['filekey'] ) { + // defer verification to background process + } else { + wfDebug( __METHOD__ . " about to verify\n" ); + $this->verifyUpload(); + } // Check if the user has the rights to modify or overwrite the requested title // (This check is irrelevant if stashing is already requested, since the errors -- 2.20.1