Переглянути джерело

Merge pull request #18583 from nextcloud/enh/18579/chrome-regex-brave-vivaldi-opera

Modify regex to match some other chromium browsers
tags/v18.0.0RC1
Roeland Jago Douma 4 роки тому
джерело
коміт
c347b7cc14
Аккаунт користувача з таким Email не знайдено

+ 1
- 1
lib/private/AppFramework/Http/Request.php Переглянути файл

// Firefox User Agent from https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference // Firefox User Agent from https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference
const USER_AGENT_FIREFOX = '/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/[0-9.]+$/'; const USER_AGENT_FIREFOX = '/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/[0-9.]+$/';
// Chrome User Agent from https://developer.chrome.com/multidevice/user-agent // Chrome User Agent from https://developer.chrome.com/multidevice/user-agent
const USER_AGENT_CHROME = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)( Ubuntu Chromium\/[0-9.]+|) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+$/';
const USER_AGENT_CHROME = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)( Ubuntu Chromium\/[0-9.]+|) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+( (Vivaldi|Brave|OPR)\/[0-9.]+|)$/';
// Safari User Agent from http://www.useragentstring.com/pages/Safari/ // Safari User Agent from http://www.useragentstring.com/pages/Safari/
const USER_AGENT_SAFARI = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Version\/[0-9.]+ Safari\/[0-9.A-Z]+$/'; const USER_AGENT_SAFARI = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Version\/[0-9.]+ Safari\/[0-9.A-Z]+$/';
// Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent // Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent

+ 26
- 5
tests/lib/AppFramework/Http/RequestTest.php Переглянути файл

} }




public function testImmutableArrayAccess() { public function testImmutableArrayAccess() {
$this->expectException(\RuntimeException::class); $this->expectException(\RuntimeException::class);


$request['nickname'] = 'Janey'; $request['nickname'] = 'Janey';
} }


public function testImmutableMagicAccess() { public function testImmutableMagicAccess() {
$this->expectException(\RuntimeException::class); $this->expectException(\RuntimeException::class);


$request->{'nickname'} = 'Janey'; $request->{'nickname'} = 'Janey';
} }


public function testGetTheMethodRight() { public function testGetTheMethodRight() {
$this->expectException(\LogicException::class); $this->expectException(\LogicException::class);


], ],
true, true,
], ],
[
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.99 Safari/537.36 Vivaldi/2.9.1705.41',
[
Request::USER_AGENT_CHROME
],
true
],
[
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.38 Safari/537.36 Brave/75',
[
Request::USER_AGENT_CHROME
],
true
],
[
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 OPR/50.0.2762.67',
[
Request::USER_AGENT_CHROME
],
true
]
]; ];
} }


$this->assertSame('www.owncloud.org', self::invokePrivate($request, 'getOverwriteHost')); $this->assertSame('www.owncloud.org', self::invokePrivate($request, 'getOverwriteHost'));
} }


public function testGetPathInfoNotProcessible() { public function testGetPathInfoNotProcessible() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('The requested uri(/foo.php) cannot be processed by the script \'/var/www/index.php\')'); $this->expectExceptionMessage('The requested uri(/foo.php) cannot be processed by the script \'/var/www/index.php\')');
$request->getPathInfo(); $request->getPathInfo();
} }


public function testGetRawPathInfoNotProcessible() { public function testGetRawPathInfoNotProcessible() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('The requested uri(/foo.php) cannot be processed by the script \'/var/www/index.php\')'); $this->expectExceptionMessage('The requested uri(/foo.php) cannot be processed by the script \'/var/www/index.php\')');

Завантаження…
Відмінити
Зберегти