From 59ca7931e1175002d58392ebe3a992bdf7dbe295 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Tue, 31 May 2022 19:31:52 +0000 Subject: [PATCH] Validate custom dashboard background image Signed-off-by: Christopher Ng --- apps/dashboard/lib/Service/BackgroundService.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/dashboard/lib/Service/BackgroundService.php b/apps/dashboard/lib/Service/BackgroundService.php index f9bd987bdcac2..0619fd8d30428 100644 --- a/apps/dashboard/lib/Service/BackgroundService.php +++ b/apps/dashboard/lib/Service/BackgroundService.php @@ -149,6 +149,10 @@ public function setFileBackground($path): void { $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')); }