diff options
author | Georg Ehrke <developer@georgehrke.com> | 2014-03-13 12:32:02 +0100 |
---|---|---|
committer | Georg Ehrke <developer@georgehrke.com> | 2014-03-13 12:32:13 +0100 |
commit | f43833749301a8c8ea605d08897ffbc422c8d560 (patch) | |
tree | 256d729f3c75739da88e570fdcc9c8d783985cac /lib | |
parent | 8048868bd7cc55716127d1c9fa40a0c32db8b901 (diff) | |
download | nextcloud-server-f43833749301a8c8ea605d08897ffbc422c8d560.tar.gz nextcloud-server-f43833749301a8c8ea605d08897ffbc422c8d560.zip |
improve validation of getFileInfo in \OC\Preview
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/private/preview.php | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/private/preview.php b/lib/private/preview.php index 8cef1ade01b..1f797c7e994 100755 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -189,7 +189,10 @@ class Preview { $this->file = $file; $this->info = null; if ($file !== '') { - $this->mimetype = $this->getFileInfo()->getMimetype(); + $this->getFileInfo(); + if($this->info !== null && $this->info !== false) { + $this->mimetype = $this->info->getMimetype(); + } } return $this; } @@ -282,10 +285,13 @@ class Preview { $file = $this->getFile(); $fileInfo = $this->getFileInfo($file); - $fileId = $fileInfo->getId(); + if($fileInfo !== null && $fileInfo !== false) { + $fileId = $fileInfo->getId(); - $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png'; - return $this->userView->unlink($previewPath); + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png'; + return $this->userView->unlink($previewPath); + } + return false; } /** @@ -296,11 +302,14 @@ class Preview { $file = $this->getFile(); $fileInfo = $this->getFileInfo($file); - $fileId = $fileInfo->getId(); + if($fileInfo !== null && $fileInfo !== false) { + $fileId = $fileInfo->getId(); - $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/'; - $this->userView->deleteAll($previewPath); - return $this->userView->rmdir($previewPath); + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/'; + $this->userView->deleteAll($previewPath); + return $this->userView->rmdir($previewPath); + } + return false; } /** @@ -406,6 +415,9 @@ class Preview { $scalingUp = $this->getScalingUp(); $fileInfo = $this->getFileInfo($file); + if($fileInfo === null || $fileInfo === false) { + return new \OC_Image(); + } $fileId = $fileInfo->getId(); $cached = $this->isCached(); |