aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-11-05 08:46:42 +0000
committerMario <mario@mariovavti.com>2020-11-05 08:46:42 +0000
commitbafbf0416462c6f18c3fb6c8c06a063c8d6fdae6 (patch)
tree8929845be585b09d0f420621281c5531e1efad3e /vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
parent6f93d9848c43019d43ea76c27d42d657ba031cd7 (diff)
parentfdefa101d84dc2a9424eaedbdb003a4c30ec5d01 (diff)
downloadvolse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.tar.gz
volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.tar.bz2
volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.zip
Merge branch '5.0RC'5.0
Diffstat (limited to 'vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php')
-rw-r--r--vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php63
1 files changed, 34 insertions, 29 deletions
diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
index 350ecb145..17bc245c5 100644
--- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
+++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
@@ -11,7 +11,6 @@ use Sabre\Uri;
/**
* PDO principal backend.
*
- *
* This backend assumes all principals are in a single collection. The default collection
* is 'principals/', but this can be overridden.
*
@@ -65,8 +64,6 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport
/**
* Sets up the backend.
- *
- * @param \PDO $pdo
*/
public function __construct(\PDO $pdo)
{
@@ -176,8 +173,7 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport
*
* Read the PropPatch documentation for more info and examples.
*
- * @param string $path
- * @param DAV\PropPatch $propPatch
+ * @param string $path
*/
public function updatePrincipal($path, DAV\PropPatch $propPatch)
{
@@ -233,7 +229,6 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport
* from working.
*
* @param string $prefixPath
- * @param array $searchProperties
* @param string $test
*
* @return array
@@ -301,34 +296,46 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport
*/
public function findByUri($uri, $principalPrefix)
{
- $value = null;
- $scheme = null;
- list($scheme, $value) = explode(':', $uri, 2);
- if (empty($value)) {
+ $uriParts = Uri\parse($uri);
+
+ // Only two types of uri are supported :
+ // - the "mailto:" scheme with some non-empty address
+ // - a principals uri, in the form "principals/NAME"
+ // In both cases, `path` must not be empty.
+ if (empty($uriParts['path'])) {
return null;
}
$uri = null;
- switch ($scheme) {
- case 'mailto':
- $query = 'SELECT uri FROM '.$this->tableName.' WHERE lower(email)=lower(?)';
- $stmt = $this->pdo->prepare($query);
- $stmt->execute([$value]);
+ if ('mailto' === $uriParts['scheme']) {
+ $query = 'SELECT uri FROM '.$this->tableName.' WHERE lower(email)=lower(?)';
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute([$uriParts['path']]);
- while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
- // Checking if the principal is in the prefix
- list($rowPrefix) = Uri\split($row['uri']);
- if ($rowPrefix !== $principalPrefix) {
- continue;
- }
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ // Checking if the principal is in the prefix
+ list($rowPrefix) = Uri\split($row['uri']);
+ if ($rowPrefix !== $principalPrefix) {
+ continue;
+ }
+
+ $uri = $row['uri'];
+ break; //Stop on first match
+ }
+ } else {
+ $pathParts = Uri\split($uriParts['path']); // We can do this since $uriParts['path'] is not null
- $uri = $row['uri'];
- break; //Stop on first match
+ if (2 === count($pathParts) && $pathParts[0] === $principalPrefix) {
+ // Checking that this uri exists
+ $query = 'SELECT * FROM '.$this->tableName.' WHERE uri = ?';
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute([$uriParts['path']]);
+ $rows = $stmt->fetchAll();
+
+ if (count($rows) > 0) {
+ $uri = $uriParts['path'];
}
- break;
- default:
- //unsupported uri scheme
- return null;
+ }
}
return $uri;
@@ -388,7 +395,6 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport
* The principals should be passed as a list of uri's.
*
* @param string $principal
- * @param array $members
*/
public function setGroupMemberSet($principal, array $members)
{
@@ -427,7 +433,6 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport
* of the principal.
*
* @param string $path
- * @param MkCol $mkCol
*/
public function createPrincipal($path, MkCol $mkCol)
{