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
path: root/inc
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2010-09-08 04:01:30 +0400
committerRobin Appelman <icewind1991@gmail.com>2010-09-08 04:04:07 +0400
commit420178bec8d7716ee855af07b7a95fea972ac05c (patch)
treef83daad3e14a319c5ba82b7ca13e5a1a70017748 /inc
parentcffa4edb722b080091cb417b734dbff1907eafb2 (diff)
fix fallback for mimetype detection using the 'file' command
Diffstat (limited to 'inc')
-rw-r--r--inc/lib_filestorage.php16
1 files changed, 3 insertions, 13 deletions
diff --git a/inc/lib_filestorage.php b/inc/lib_filestorage.php
index 62532916ca5..3e53e266279 100644
--- a/inc/lib_filestorage.php
+++ b/inc/lib_filestorage.php
@@ -223,22 +223,12 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
} else if (self::canExecute("file")) {
// it looks like we have a 'file' command,
// lets see it it does have mime support
- $fp = popen("file -i '$fspath' 2>/dev/null", "r");
+ $fp = popen("file -i -b '{$this->datadir}$fspath' 2>/dev/null", "r");
$reply = fgets($fp);
pclose($fp);
- // popen will not return an error if the binary was not found
- // and find may not have mime support using "-i"
- // so we test the format of the returned string
-
- // the reply begins with the requested filename
- if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
- $reply = substr($reply, strlen($fspath)+2);
- // followed by the mime type (maybe including options)
- if (preg_match('/^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*/', $reply, $matches)) {
- $mime_type = $matches[0];
- }
- }
+ //trim the character set from the end of the response
+ $mime_type=substr($reply,0,strrpos($reply,' '));
}
if (empty($mime_type)) {
// Fallback solution: try to guess the type by the file extension