Revert "Always validate uploads over api"
authorHashar <hashar@free.fr>
Fri, 17 May 2019 14:42:21 +0000 (14:42 +0000)
committerHashar <hashar@free.fr>
Fri, 17 May 2019 14:42:44 +0000 (14:42 +0000)
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

index f0d271c..fc41e4e 100644 (file)
@@ -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