Skip to content

Commit

Permalink
Catch not existing User-Agent header
Browse files Browse the repository at this point in the history
In case of an not sent UA header consider the client as valid
  • Loading branch information
LukasReschke committed Apr 23, 2015
1 parent 21ad440 commit ab9ea97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/private/connector/sabre/blocklegacyclientplugin.php
Expand Up @@ -46,7 +46,7 @@ public function __construct(IConfig $config) {
}

/**
* @param \Sabre\DAV\ $server
* @param \Sabre\DAV\Server $server
* @return void
*/
public function initialize(\Sabre\DAV\Server $server) {
Expand All @@ -62,6 +62,10 @@ public function initialize(\Sabre\DAV\Server $server) {
*/
public function beforeHandler(RequestInterface $request) {
$userAgent = $request->getHeader('User-Agent');
if($userAgent === null) {
return;
}

$minimumSupportedDesktopVersion = $this->config->getSystemValue('minimum.supported.desktop.version', '1.7.0');

// Match on the mirall version which is in scheme "Mozilla/5.0 (%1) mirall/%2" or
Expand Down
13 changes: 12 additions & 1 deletion tests/lib/connector/sabre/BlockLegacyClientPluginTest.php
Expand Up @@ -97,7 +97,7 @@ public function newAndAlternateDesktopClientProvider() {
* @dataProvider newAndAlternateDesktopClientProvider
* @param string $userAgent
*/
public function testBeforeHandlerSucess($userAgent) {
public function testBeforeHandlerSuccess($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface');
$request
Expand All @@ -115,4 +115,15 @@ public function testBeforeHandlerSucess($userAgent) {
$this->blockLegacyClientVersionPlugin->beforeHandler($request);
}

public function testBeforeHandlerNoUserAgent() {
/** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface');
$request
->expects($this->once())
->method('getHeader')
->with('User-Agent')
->will($this->returnValue(null));
$this->blockLegacyClientVersionPlugin->beforeHandler($request);
}

}

0 comments on commit ab9ea97

Please sign in to comment.