summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php8
-rw-r--r--lib/private/files.php7
-rw-r--r--lib/private/mimetypes.list.php3
-rwxr-xr-xlib/private/request.php23
-rw-r--r--lib/private/response.php14
-rw-r--r--lib/public/response.php9
6 files changed, 54 insertions, 10 deletions
diff --git a/lib/base.php b/lib/base.php
index d3e483f4948..a8e9e901847 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -410,8 +410,6 @@ class OC {
self::$loader->registerPrefix('Doctrine\\DBAL', 'doctrine/dbal/lib');
self::$loader->registerPrefix('Symfony\\Component\\Routing', 'symfony/routing');
self::$loader->registerPrefix('Symfony\\Component\\Console', 'symfony/console');
- self::$loader->registerPrefix('Sabre\\VObject', '3rdparty');
- self::$loader->registerPrefix('Sabre_', '3rdparty');
self::$loader->registerPrefix('Patchwork', '3rdparty');
spl_autoload_register(array(self::$loader, 'load'));
@@ -479,6 +477,12 @@ class OC {
}
OC_Util::isSetLocaleWorking();
+ // setup 3rdparty autoloader
+ $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php';
+ if (file_exists($vendorAutoLoad)) {
+ require_once $vendorAutoLoad;
+ }
+
// set debug mode if an xdebug session is active
if (!defined('DEBUG') || !DEBUG) {
if (isset($_COOKIE['XDEBUG_SESSION'])) {
diff --git a/lib/private/files.php b/lib/private/files.php
index 6ffa14c0d91..e6c81d58bd2 100644
--- a/lib/private/files.php
+++ b/lib/private/files.php
@@ -115,12 +115,7 @@ class OC_Files {
}
OC_Util::obEnd();
if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
- if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) {
- header( 'Content-Disposition: attachment; filename="' . rawurlencode($name) . '"' );
- } else {
- header( 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($name)
- . '; filename="' . rawurlencode($name) . '"' );
- }
+ OC_Response::setContentDispositionHeader($name, 'attachment');
header('Content-Transfer-Encoding: binary');
OC_Response::disableCaching();
if ($zip) {
diff --git a/lib/private/mimetypes.list.php b/lib/private/mimetypes.list.php
index 740982910e0..08228336966 100644
--- a/lib/private/mimetypes.list.php
+++ b/lib/private/mimetypes.list.php
@@ -66,6 +66,7 @@ return array(
'xlsx'=>'application/msexcel',
'php'=>'application/x-php',
'exe'=>'application/x-ms-dos-executable',
+ 'msi'=>'application/x-msi',
'pl'=>'application/x-pearl',
'py'=>'application/x-python',
'blend'=>'application/x-blender',
@@ -97,8 +98,6 @@ return array(
'ai' => 'application/illustrator',
'epub' => 'application/epub+zip',
'mobi' => 'application/x-mobipocket-ebook',
- 'exe' => 'application',
- 'msi' => 'application',
'md' => 'text/markdown',
'markdown' => 'text/markdown',
'mdown' => 'text/markdown',
diff --git a/lib/private/request.php b/lib/private/request.php
index b2afda35922..d9d5ae08e28 100755
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -7,6 +7,11 @@
*/
class OC_Request {
+
+ const USER_AGENT_IE = '/MSIE/';
+ // Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent
+ const USER_AGENT_ANDROID_MOBILE_CHROME = '#Android.*Chrome/[.0-9]*#';
+
/**
* @brief Check overwrite condition
* @param string $type
@@ -210,4 +215,22 @@ class OC_Request {
return false;
}
}
+
+ /**
+ * Checks whether the user agent matches a given regex
+ * @param string|array $agent agent name or array of agent names
+ * @return boolean true if at least one of the given agent matches,
+ * false otherwise
+ */
+ static public function isUserAgent($agent) {
+ if (!is_array($agent)) {
+ $agent = array($agent);
+ }
+ foreach ($agent as $regex) {
+ if (preg_match($regex, $_SERVER['HTTP_USER_AGENT'])) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/lib/private/response.php b/lib/private/response.php
index 674176d078b..04746437347 100644
--- a/lib/private/response.php
+++ b/lib/private/response.php
@@ -148,6 +148,20 @@ class OC_Response {
}
/**
+ * Sets the content disposition header (with possible workarounds)
+ * @param string $filename file name
+ * @param string $type disposition type, either 'attachment' or 'inline'
+ */
+ static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
+ if (OC_Request::isUserAgent(array(OC_Request::USER_AGENT_IE, OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME))) {
+ header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' );
+ } else {
+ header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename )
+ . '; filename="' . rawurlencode( $filename ) . '"' );
+ }
+ }
+
+ /**
* @brief Send file as response, checking and setting caching headers
* @param $filepath of file to send
*/
diff --git a/lib/public/response.php b/lib/public/response.php
index 2ca0a0c9fa4..24d3c81d628 100644
--- a/lib/public/response.php
+++ b/lib/public/response.php
@@ -55,6 +55,15 @@ class Response {
}
/**
+ * Sets the content disposition header (with possible workarounds)
+ * @param string $filename file name
+ * @param string $type disposition type, either 'attachment' or 'inline'
+ */
+ static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
+ \OC_Response::setContentDispositionHeader( $filename, $type );
+ }
+
+ /**
* Disable browser caching
* @see enableCaching with cache_time = 0
*/