diff --git a/system/Validation/FileRules.php b/system/Validation/FileRules.php index ea1a6f678379..2becb34b1950 100644 --- a/system/Validation/FileRules.php +++ b/system/Validation/FileRules.php @@ -133,7 +133,7 @@ public function is_image(?string $blank, string $params): bool // We know that our mimes list always has the first mime // start with `image` even when then are multiple accepted types. - $type = Mimes::guessTypeFromExtension($file->getExtension()); + $type = Mimes::guessTypeFromExtension($file->getExtension()) ?? ''; if (mb_strpos($type, 'image') !== 0) { return false; diff --git a/tests/_support/Validation/uploads/abc77tz b/tests/_support/Validation/uploads/abc77tz new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/system/Validation/FileRulesTest.php b/tests/system/Validation/FileRulesTest.php index 0a2f5356efd8..8c5ce6e142ac 100644 --- a/tests/system/Validation/FileRulesTest.php +++ b/tests/system/Validation/FileRulesTest.php @@ -41,7 +41,9 @@ final class FileRulesTest extends CIUnitTestCase protected function setUp(): void { + $this->resetServices(); parent::setUp(); + $this->validation = new Validation((object) $this->config, Services::renderer()); $this->validation->reset(); @@ -229,6 +231,7 @@ public function testIsntImage(): void 'type' => 'application/address', 'error' => UPLOAD_ERR_OK, ]; + $this->validation->setRules(['avatar' => 'is_image[stuff]']); $this->assertFalse($this->validation->run([])); }