diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-01-08 18:33:35 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-01-08 18:38:17 +0100 |
commit | ceaaab6295ad30e066c9d5505e9131136bafbdb8 (patch) | |
tree | a18a83a8878e34400157232ef89487fb8899d3bc /core/ajax | |
parent | af269258d3dbcb610dad3bd241464845425d5123 (diff) | |
download | nextcloud-server-ceaaab6295ad30e066c9d5505e9131136bafbdb8.tar.gz nextcloud-server-ceaaab6295ad30e066c9d5505e9131136bafbdb8.zip |
Verify whether type is correct
`$this->info` can very well contain an empty array or possibly other values. This means that when this code path is called a PHP Fatal error might get thrown which is not what we want.
Diffstat (limited to 'core/ajax')
-rw-r--r-- | core/ajax/preview.php | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/core/ajax/preview.php b/core/ajax/preview.php index 03dfb483062..f7e24e0ec28 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -29,21 +29,17 @@ if ($maxX === 0 || $maxY === 0) { exit; } -try { - $preview = new \OC\Preview(\OC_User::getUser(), 'files'); - $info = \OC\Files\Filesystem::getFileInfo($file); - if (!$always and !$preview->isAvailable($info)) { - \OC_Response::setStatus(404); - } else { - $preview->setFile($file); - $preview->setMaxX($maxX); - $preview->setMaxY($maxY); - $preview->setScalingUp($scalingUp); - $preview->setKeepAspect($keepAspect); - $preview->showPreview(); - } +$preview = new \OC\Preview(\OC_User::getUser(), 'files'); -} catch (\Exception $e) { - \OC_Response::setStatus(500); - \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG); +$info = \OC\Files\Filesystem::getFileInfo($file); + +if (!$info instanceof OCP\Files\FileInfo || !$always && !$preview->isAvailable($info)) { + \OC_Response::setStatus(404); +} else { + $preview->setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + $preview->setKeepAspect($keepAspect); + $preview->showPreview(); } |