]> source.dussan.org Git - nextcloud-server.git/commitdiff
Validate custom dashboard background image 32675/head
authorChristopher Ng <chrng8@gmail.com>
Tue, 31 May 2022 19:31:52 +0000 (19:31 +0000)
committerChristopher Ng <chrng8@gmail.com>
Thu, 2 Jun 2022 00:24:35 +0000 (00:24 +0000)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/dashboard/lib/Service/BackgroundService.php

index 13ad03cf860d938e6eb5067c822512bb156ee49b..c98b92412cbb551f3099f53c3943a1ed07d6095a 100644 (file)
@@ -150,6 +150,10 @@ class BackgroundService {
                $userFolder = $this->rootFolder->getUserFolder($this->userId);
                /** @var File $file */
                $file = $userFolder->get($path);
+               $image = new \OCP\Image();
+               if ($image->loadFromFileHandle($file->fopen('r')) === false) {
+                       throw new InvalidArgumentException('Invalid image file');
+               }
                $this->getAppDataFolder()->newFile('background.jpg', $file->fopen('r'));
        }