[Pkg-owncloud-commits] [owncloud] 33/215: Catch not existing User-Agent header

David Prévot taffit at moszumanska.debian.org
Tue May 5 01:01:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit ab9ea97d3af62fd1c9c1f813b84e5c45a585a8d8
Author: Lukas Reschke <lukas at owncloud.com>
Date:   Thu Apr 23 16:33:51 2015 +0200

    Catch not existing User-Agent header
    
    In case of an not sent UA header consider the client as valid
---
 lib/private/connector/sabre/blocklegacyclientplugin.php   |  6 +++++-
 tests/lib/connector/sabre/BlockLegacyClientPluginTest.php | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/private/connector/sabre/blocklegacyclientplugin.php b/lib/private/connector/sabre/blocklegacyclientplugin.php
index 7da6ff5..9480cd1 100644
--- a/lib/private/connector/sabre/blocklegacyclientplugin.php
+++ b/lib/private/connector/sabre/blocklegacyclientplugin.php
@@ -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
diff --git a/tests/lib/connector/sabre/BlockLegacyClientPluginTest.php b/tests/lib/connector/sabre/BlockLegacyClientPluginTest.php
index 2c7835d..05488d9 100644
--- a/tests/lib/connector/sabre/BlockLegacyClientPluginTest.php
+++ b/tests/lib/connector/sabre/BlockLegacyClientPluginTest.php
@@ -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);
+	}
+
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list