Merge pull request #6952 from MartialGeek/add_freebox_support

New user agent added for the Freebox.
This commit is contained in:
Vincent Petry 2014-02-06 18:12:32 +01:00
commit be47e156a5
3 changed files with 21 additions and 1 deletions

View File

@ -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

View 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 )

View File

@ -118,6 +118,21 @@ class Test_Request extends PHPUnit_Framework_TestCase {
),
true
),
array(
'Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0',
OC_Request::USER_AGENT_FREEBOX,
false
),
array(
'Mozilla/5.0',
OC_Request::USER_AGENT_FREEBOX,
true
),
array(
'Fake Mozilla/5.0',
OC_Request::USER_AGENT_FREEBOX,
false
),
);
}
}