Commit ab9ea97d authored by Lukas Reschke's avatar Lukas Reschke
Browse files

Catch not existing User-Agent header

In case of an not sent UA header consider the client as valid
parent 21ad4400
......@@ -46,7 +46,7 @@ class BlockLegacyClientPlugin extends ServerPlugin {
}
/**
* @param \Sabre\DAV\ $server
* @param \Sabre\DAV\Server $server
* @return void
*/
public function initialize(\Sabre\DAV\Server $server) {
......@@ -62,6 +62,10 @@ class BlockLegacyClientPlugin extends ServerPlugin {
*/
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
......
......@@ -97,7 +97,7 @@ class BlockLegacyClientPluginTest extends TestCase {
* @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
......@@ -115,4 +115,15 @@ class BlockLegacyClientPluginTest extends TestCase {
$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);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment