[Pkg-owncloud-commits] [php-sabredav] 16/75: Issue #581 : Fixed blank principalPrefix in findByUri

David Prévot taffit at moszumanska.debian.org
Thu Feb 26 18:51:49 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 814f6492f0c61aa5d16686f08c2acbbf4ae1ebf1
Author: Aneece Yazdani <aneece at cpanel.net>
Date:   Mon Feb 9 09:39:16 2015 -0600

    Issue #581 : Fixed blank principalPrefix in findByUri
    
    The principalPrefix sent to searchPrincipals was set to a literal blank
    string and would never return a valid result unless no prefix was used.
---
 lib/DAVACL/AbstractPrincipalCollection.php       | 2 +-
 lib/DAVACL/PrincipalBackend/AbstractBackend.php  | 5 +++--
 lib/DAVACL/PrincipalBackend/BackendInterface.php | 3 ++-
 tests/Sabre/DAVACL/PrincipalCollectionTest.php   | 9 +++++++++
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/DAVACL/AbstractPrincipalCollection.php b/lib/DAVACL/AbstractPrincipalCollection.php
index df1c3b5..c63f9f1 100644
--- a/lib/DAVACL/AbstractPrincipalCollection.php
+++ b/lib/DAVACL/AbstractPrincipalCollection.php
@@ -174,7 +174,7 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr
      */
     function findByUri($uri) {
 
-        return $this->principalBackend->findByUri($uri);
+        return $this->principalBackend->findByUri($uri, $this->principalPrefix);
 
     }
 
diff --git a/lib/DAVACL/PrincipalBackend/AbstractBackend.php b/lib/DAVACL/PrincipalBackend/AbstractBackend.php
index 34fabda..2437cda 100644
--- a/lib/DAVACL/PrincipalBackend/AbstractBackend.php
+++ b/lib/DAVACL/PrincipalBackend/AbstractBackend.php
@@ -29,9 +29,10 @@ abstract class AbstractBackend implements BackendInterface {
      * principal was not found or you refuse to find it.
      *
      * @param string $uri
+     * @param string $principalPrefix
      * @return string
      */
-    function findByUri($uri) {
+    function findByUri($uri, $principalPrefix) {
 
         // Note that the default implementation here is a bit slow and could
         // likely be optimized.
@@ -39,7 +40,7 @@ abstract class AbstractBackend implements BackendInterface {
             return;
         }
         $result = $this->searchPrincipals(
-            '',
+            $principalPrefix,
             ['{http://sabredav.org/ns}email-address' => substr($uri,7)]
         );
 
diff --git a/lib/DAVACL/PrincipalBackend/BackendInterface.php b/lib/DAVACL/PrincipalBackend/BackendInterface.php
index 94db941..d6a5b13 100644
--- a/lib/DAVACL/PrincipalBackend/BackendInterface.php
+++ b/lib/DAVACL/PrincipalBackend/BackendInterface.php
@@ -106,9 +106,10 @@ interface BackendInterface {
      * principal was not found or you refuse to find it.
      *
      * @param string $uri
+     * @param string $principalPrefix
      * @return string
      */
-    function findByUri($uri);
+    function findByUri($uri, $principalPrefix);
 
     /**
      * Returns the list of members for a group-principal
diff --git a/tests/Sabre/DAVACL/PrincipalCollectionTest.php b/tests/Sabre/DAVACL/PrincipalCollectionTest.php
index 10b0c04..f51d2dc 100644
--- a/tests/Sabre/DAVACL/PrincipalCollectionTest.php
+++ b/tests/Sabre/DAVACL/PrincipalCollectionTest.php
@@ -49,4 +49,13 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase {
 
     }
 
+    public function testFindByUri() {
+
+        $backend = new PrincipalBackend\Mock();
+        $pc = new PrincipalCollection($backend);
+        $this->assertEquals('principals/user1', $pc->findByUri('mailto:user1.sabredav at sabredav.org'));
+        $this->assertNull($pc->findByUri('mailto:fake.user.sabredav at sabredav.org'));
+        $this->assertNull($pc->findByUri(''));
+    }
+
 }

-- 
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