Skip to content

Commit ab9ea97

Browse files
committed
Catch not existing User-Agent header
In case of an not sent UA header consider the client as valid
1 parent 21ad440 commit ab9ea97

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/private/connector/sabre/blocklegacyclientplugin.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(IConfig $config) {
4646
}
4747

4848
/**
49-
* @param \Sabre\DAV\ $server
49+
* @param \Sabre\DAV\Server $server
5050
* @return void
5151
*/
5252
public function initialize(\Sabre\DAV\Server $server) {
@@ -62,6 +62,10 @@ public function initialize(\Sabre\DAV\Server $server) {
6262
*/
6363
public function beforeHandler(RequestInterface $request) {
6464
$userAgent = $request->getHeader('User-Agent');
65+
if($userAgent === null) {
66+
return;
67+
}
68+
6569
$minimumSupportedDesktopVersion = $this->config->getSystemValue('minimum.supported.desktop.version', '1.7.0');
6670

6771
// Match on the mirall version which is in scheme "Mozilla/5.0 (%1) mirall/%2" or

tests/lib/connector/sabre/BlockLegacyClientPluginTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function newAndAlternateDesktopClientProvider() {
9797
* @dataProvider newAndAlternateDesktopClientProvider
9898
* @param string $userAgent
9999
*/
100-
public function testBeforeHandlerSucess($userAgent) {
100+
public function testBeforeHandlerSuccess($userAgent) {
101101
/** @var \Sabre\HTTP\RequestInterface $request */
102102
$request = $this->getMock('\Sabre\HTTP\RequestInterface');
103103
$request
@@ -115,4 +115,15 @@ public function testBeforeHandlerSucess($userAgent) {
115115
$this->blockLegacyClientVersionPlugin->beforeHandler($request);
116116
}
117117

118+
public function testBeforeHandlerNoUserAgent() {
119+
/** @var \Sabre\HTTP\RequestInterface $request */
120+
$request = $this->getMock('\Sabre\HTTP\RequestInterface');
121+
$request
122+
->expects($this->once())
123+
->method('getHeader')
124+
->with('User-Agent')
125+
->will($this->returnValue(null));
126+
$this->blockLegacyClientVersionPlugin->beforeHandler($request);
127+
}
128+
118129
}

0 commit comments

Comments
 (0)