Validate custom dashboard background image

Signed-off-by: Christopher Ng <chrng8@gmail.com>
pull/32675/head
Christopher Ng 2022-05-31 19:31:52 +07:00
parent 581bb62d9c
commit 00135986ab
1 changed files with 4 additions and 0 deletions

@ -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'));
}