Merge pull request #5276 from owncloud/fixing-5170-master

only text/plain is now used to generate text previews
This commit is contained in:
Morris Jobke 2013-10-16 14:21:40 -07:00
commit 04783da829
1 changed files with 12 additions and 23 deletions

View File

@ -9,20 +9,19 @@ namespace OC\Preview;
class TXT extends Provider { class TXT extends Provider {
private static $blacklist = array(
'text/calendar',
'text/vcard',
);
public function getMimeType() { public function getMimeType() {
return '/text\/.*/'; return '/text\/plain/';
} }
/**
* @param string $path
* @param int $maxX
* @param int $maxY
* @param boolean $scalingup
* @param \OC\Files\View $fileview
* @return bool|\OC_Image
*/
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
$mimetype = $fileview->getMimeType($path);
if(in_array($mimetype, self::$blacklist)) {
return false;
}
$content = $fileview->fopen($path, 'r'); $content = $fileview->fopen($path, 'r');
$content = stream_get_contents($content); $content = stream_get_contents($content);
@ -62,22 +61,12 @@ class TXT extends Provider {
\OC\Preview::registerProvider('OC\Preview\TXT'); \OC\Preview::registerProvider('OC\Preview\TXT');
class PHP extends TXT { class MarkDown extends TXT {
public function getMimeType() { public function getMimeType() {
return '/application\/x-php/'; return '/text\/(x-)?markdown/';
} }
} }
\OC\Preview::registerProvider('OC\Preview\PHP'); \OC\Preview::registerProvider('OC\Preview\MarkDown');
class JavaScript extends TXT {
public function getMimeType() {
return '/application\/javascript/';
}
}
\OC\Preview::registerProvider('OC\Preview\JavaScript');