summaryrefslogtreecommitdiffstats
path: root/core/ajax
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-01-08 18:33:35 +0100
committerLukas Reschke <lukas@owncloud.com>2015-01-08 18:38:17 +0100
commitceaaab6295ad30e066c9d5505e9131136bafbdb8 (patch)
treea18a83a8878e34400157232ef89487fb8899d3bc /core/ajax
parentaf269258d3dbcb610dad3bd241464845425d5123 (diff)
downloadnextcloud-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.php28
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();
}