[Pkg-owncloud-commits] [php-sabredav] 03/75: Support empty usernames and passwords in basic auth. Fixes #568
David Prévot
taffit at moszumanska.debian.org
Thu Feb 26 18:51:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 49104623ae10caf58649a93f25de6b098de60f0f
Author: Evert Pot <me at evertpot.com>
Date: Thu Jan 15 16:06:20 2015 -0500
Support empty usernames and passwords in basic auth. Fixes #568
---
lib/Sabre/HTTP/BasicAuth.php | 2 +-
tests/Sabre/HTTP/BasicAuthTest.php | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/lib/Sabre/HTTP/BasicAuth.php b/lib/Sabre/HTTP/BasicAuth.php
index 74a8b96..18fe163 100644
--- a/lib/Sabre/HTTP/BasicAuth.php
+++ b/lib/Sabre/HTTP/BasicAuth.php
@@ -27,7 +27,7 @@ class BasicAuth extends AbstractAuth {
public function getUserPass() {
// Apache and mod_php
- if (($user = $this->httpRequest->getRawServerValue('PHP_AUTH_USER')) && ($pass = $this->httpRequest->getRawServerValue('PHP_AUTH_PW'))) {
+ if (($user = $this->httpRequest->getRawServerValue('PHP_AUTH_USER'))!==null && ($pass = $this->httpRequest->getRawServerValue('PHP_AUTH_PW'))!==null) {
return array($user,$pass);
diff --git a/tests/Sabre/HTTP/BasicAuthTest.php b/tests/Sabre/HTTP/BasicAuthTest.php
index 77c5c71..19b5033 100644
--- a/tests/Sabre/HTTP/BasicAuthTest.php
+++ b/tests/Sabre/HTTP/BasicAuthTest.php
@@ -43,6 +43,26 @@ class BasicAuthTest extends \PHPUnit_Framework_TestCase {
}
+ function testGetUserPassPasswordEmpty() {
+
+ $server = array(
+ 'PHP_AUTH_USER' => 'admin',
+ 'PHP_AUTH_PW' => '',
+ );
+
+ $request = new Request($server);
+ $this->basicAuth->setHTTPRequest($request);
+
+ $userPass = $this->basicAuth->getUserPass();
+
+ $this->assertEquals(
+ array('admin',''),
+ $userPass,
+ 'We did not get the username and password we expected'
+ );
+
+ }
+
function testGetUserPassIIS() {
$server = array(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list