diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 8db0ffead4ec216634d0de58121649802ff89ded..58c34e972def87c0727dd93d87eeb8e3ee40a7ff 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -140,6 +140,7 @@ class OC_Filestorage_Local extends OC_Filestorage{
 			} else if (OC_Helper::canExecute("file")) {
 				// it looks like we have a 'file' command,
 				// lets see it it does have mime support
+				$fspath=str_replace("'","\'",$fspath);
 				$fp = popen("file -i -b '{$this->datadir}$fspath' 2>/dev/null", "r");
 				$reply = fgets($fp);
 				pclose($fp);