Validate file extension before validating size
authorNiklas <Krymonota@users.noreply.github.com>
Tue, 12 May 2020 08:28:34 +0000 (10:28 +0200)
committerGitHub <noreply@github.com>
Tue, 12 May 2020 08:28:34 +0000 (10:28 +0200)
wcfsetup/install/files/lib/system/upload/DefaultUploadFileValidationStrategy.class.php

index 3a79a15d75a65b12fd00d99b1fae740d22b66208..05b6125350f2313343530aea4f3a6c05e5ddcd82 100644 (file)
@@ -52,13 +52,13 @@ class DefaultUploadFileValidationStrategy implements IUploadFileValidationStrate
                        return false;
                }
                
-               if ($uploadFile->getFilesize() > $this->maxFilesize) {
-                       $uploadFile->setValidationErrorType('tooLarge');
+               if (!preg_match($this->fileExtensionRegex, mb_strtolower($uploadFile->getFilename()))) {
+                       $uploadFile->setValidationErrorType('invalidExtension');
                        return false;
                }
                
-               if (!preg_match($this->fileExtensionRegex, mb_strtolower($uploadFile->getFilename()))) {
-                       $uploadFile->setValidationErrorType('invalidExtension');
+               if ($uploadFile->getFilesize() > $this->maxFilesize) {
+                       $uploadFile->setValidationErrorType('tooLarge');
                        return false;
                }