diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-01-09 02:27:51 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-01-09 02:27:51 +0100 |
commit | 6c5925397871b018fa6bad147b0055a6ab1d2f5d (patch) | |
tree | ec0772a2f93f834e686efbdf76504e9f7214cce1 | |
parent | 6a5f12beca175a0b9a951fa844eacfd21a8df3de (diff) | |
parent | ceaaab6295ad30e066c9d5505e9131136bafbdb8 (diff) | |
download | nextcloud-server-6c5925397871b018fa6bad147b0055a6ab1d2f5d.tar.gz nextcloud-server-6c5925397871b018fa6bad147b0055a6ab1d2f5d.zip |
Merge pull request #13179 from owncloud/fix-fatal-php-error-for-not-existing-files
Verify whether type is correct
-rw-r--r-- | core/ajax/preview.php | 28 | ||||
-rw-r--r-- | lib/private/preview.php | 5 |
2 files changed, 15 insertions, 18 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(); } diff --git a/lib/private/preview.php b/lib/private/preview.php index a586c94fd11..c7ef00652aa 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -200,14 +200,15 @@ class Preview { /** * set the path of the file you want a thumbnail from * @param string $file - * @return \OC\Preview $this + * @return $this */ public function setFile($file) { $this->file = $file; $this->info = null; + if ($file !== '') { $this->getFileInfo(); - if($this->info !== null && $this->info !== false) { + if($this->info instanceof \OCP\Files\FileInfo) { $this->mimeType = $this->info->getMimetype(); } } |