]> source.dussan.org Git - nextcloud-server.git/commitdiff
New user agent added for the Freebox.
authorMartial Saunois <saunois.martial@gmail.com>
Sun, 26 Jan 2014 17:46:09 +0000 (18:46 +0100)
committerMartial Saunois <saunois.martial@gmail.com>
Sun, 26 Jan 2014 17:46:09 +0000 (18:46 +0100)
The Freebox is the multimedia device of a french Internet provider: Free. This device provides a seedbox which uses the user agent "Mozilla/5.0". In the "Content-Disposition" header, if the "filename" key is used with the "filename*=UTF-8''" value, the seedbox does not take care about the header and saves the file name with the origin URL. This patch brings the support for the Freebox users.

lib/private/request.php
lib/private/response.php

index d9d5ae08e283896bcb0bad374c60a9cba90e14b5..855148ac25a217e3fa41c3efab6ff3827dccb5e0 100755 (executable)
@@ -11,6 +11,7 @@ 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]*#';
+       const USER_AGENT_FREEBOX = '#Mozilla/5\.0$#';
 
        /**
         * @brief Check overwrite condition
index 047464373472d50e0233a4e67a0036a542fb1cfe..52dbb9d90f88b1c44d1b0ee0367431186be7c2d9 100644 (file)
@@ -153,7 +153,11 @@ class OC_Response {
         * @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))) {
+               if (OC_Request::isUserAgent(array(
+                               OC_Request::USER_AGENT_IE,
+                               OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME,
+                               OC_Request::USER_AGENT_FREEBOX
+                       ))) {
                        header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' );
                } else {
                        header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename )