Skip to content

Commit 59ca793

Browse files
Pytalbackportbot-nextcloud[bot]
authored andcommitted
Validate custom dashboard background image
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent 254cb7a commit 59ca793

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

apps/dashboard/lib/Service/BackgroundService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ public function setFileBackground($path): void {
149149
$userFolder = $this->rootFolder->getUserFolder($this->userId);
150150
/** @var File $file */
151151
$file = $userFolder->get($path);
152+
$image = new \OCP\Image();
153+
if ($image->loadFromFileHandle($file->fopen('r')) === false) {
154+
throw new InvalidArgumentException('Invalid image file');
155+
}
152156
$this->getAppDataFolder()->newFile('background.jpg', $file->fopen('r'));
153157
}
154158

0 commit comments

Comments
 (0)