summaryrefslogtreecommitdiffstats
path: root/core/ajax
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-02-19 14:47:29 +0100
committerRobin Appelman <icewind@owncloud.com>2014-02-19 14:47:29 +0100
commit609a91a9b1bbee423a6bda2420dc4010b46757f6 (patch)
tree9def1e0df939d6015b2e4cbe4db5bcde9e907fbc /core/ajax
parentf9d4780d27ca21d86d8dacf73eda52a73a479d61 (diff)
downloadnextcloud-server-609a91a9b1bbee423a6bda2420dc4010b46757f6.tar.gz
nextcloud-server-609a91a9b1bbee423a6bda2420dc4010b46757f6.zip
Show svg mime icons when no preview is available
Diffstat (limited to 'core/ajax')
-rw-r--r--core/ajax/preview.php30
1 files changed, 17 insertions, 13 deletions
diff --git a/core/ajax/preview.php b/core/ajax/preview.php
index a1267d6f5cf..5c6d5ce25ab 100644
--- a/core/ajax/preview.php
+++ b/core/ajax/preview.php
@@ -7,34 +7,38 @@
*/
\OC_Util::checkLoggedIn();
-$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : '';
-$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
-$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
-$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
+$file = array_key_exists('file', $_GET) ? (string)$_GET['file'] : '';
+$maxX = array_key_exists('x', $_GET) ? (int)$_GET['x'] : '36';
+$maxY = array_key_exists('y', $_GET) ? (int)$_GET['y'] : '36';
+$scalingUp = array_key_exists('scalingup', $_GET) ? (bool)$_GET['scalingup'] : true;
-if($file === '') {
+if ($file === '') {
//400 Bad Request
\OC_Response::setStatus(400);
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
exit;
}
-if($maxX === 0 || $maxY === 0) {
+if ($maxX === 0 || $maxY === 0) {
//400 Bad Request
\OC_Response::setStatus(400);
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
exit;
}
-try{
+try {
$preview = new \OC\Preview(\OC_User::getUser(), 'files');
- $preview->setFile($file);
- $preview->setMaxX($maxX);
- $preview->setMaxY($maxY);
- $preview->setScalingUp($scalingUp);
+ if (!$preview->isMimeSupported(\OC\Files\Filesystem::getMimeType($file))) {
+ \OC_Response::setStatus(404);
+ } else {
+ $preview->setFile($file);
+ $preview->setMaxX($maxX);
+ $preview->setMaxY($maxY);
+ $preview->setScalingUp($scalingUp);
+ }
$preview->show();
-}catch(\Exception $e) {
+} catch (\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
-} \ No newline at end of file
+}