Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2014-03-13 15:32:02 +0400
committerGeorg Ehrke <developer@georgehrke.com>2014-03-13 15:32:13 +0400
commitf43833749301a8c8ea605d08897ffbc422c8d560 (patch)
tree256d729f3c75739da88e570fdcc9c8d783985cac /lib/private/preview.php
parent8048868bd7cc55716127d1c9fa40a0c32db8b901 (diff)
improve validation of getFileInfo in \OC\Preview
Diffstat (limited to 'lib/private/preview.php')
-rwxr-xr-xlib/private/preview.php28
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();