]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix check for Cloud ID, missing return statements, wrong param use
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 30 Jul 2020 19:10:54 +0000 (21:10 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 30 Jul 2020 19:10:54 +0000 (21:10 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/dav/lib/CardDAV/CardDavBackend.php
apps/federatedfilesharing/lib/Notifier.php

index 9d602025c7a49771e75ba3a966d891e5eb198103..8c8982719020fed3acd02876c2e908bc18c72f94 100644 (file)
@@ -974,8 +974,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                                        continue;
                                }
 
-                               if ($property === 'CLOUD' && preg_match('/[^a-zA-Z0-9 _.@\-\']/', $pattern) === 1) {
-                                       // There can be no chars in cloud ids which are not valid for user ids
+                               if ($property === 'CLOUD' && preg_match('/[^a-zA-Z0-9 :_.@\/\-\']/', $pattern) === 1) {
+                                       // There can be no chars in cloud ids which are not valid for user ids plus :/
+                                       // worst case: CA61590A-BBBC-423E-84AF-E6DF01455A53@https://my.nxt/srv/
                                        continue;
                                }
                        }
index 46081240d6a411c16dfe27a1834d929133780e83..cae3fc2aa997b3f6867c2b17207318a9e85873b0 100644 (file)
@@ -107,9 +107,7 @@ class Notifier implements INotifier {
                                        );
 
                                        $initiator = $params[0];
-                                       $initiatorDisplay = isset($params[3]) ? $params[3] : null;
                                        $owner = $params[1];
-                                       $ownerDisplay = isset($params[4]) ? $params[4] : null;
 
                                        $notification->setRichSubject(
                                                $l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'),
@@ -119,8 +117,8 @@ class Notifier implements INotifier {
                                                                'id' => $notification->getObjectId(),
                                                                'name' => $params[2],
                                                        ],
-                                                       'user' => $this->createRemoteUser($initiator, $initiatorDisplay),
-                                                       'behalf' => $this->createRemoteUser($owner, $ownerDisplay),
+                                                       'user' => $this->createRemoteUser($initiator),
+                                                       'behalf' => $this->createRemoteUser($owner),
                                                ]
                                        );
                                } else {
@@ -129,7 +127,6 @@ class Notifier implements INotifier {
                                        );
 
                                        $owner = $params[0];
-                                       $ownerDisplay = isset($params[3]) ? $params[3] : null;
 
                                        $notification->setRichSubject(
                                                $l->t('You received {share} as a remote share from {user}'),
@@ -139,7 +136,7 @@ class Notifier implements INotifier {
                                                                'id' => $notification->getObjectId(),
                                                                'name' => $params[2],
                                                        ],
-                                                       'user' => $this->createRemoteUser($owner, $ownerDisplay),
+                                                       'user' => $this->createRemoteUser($owner),
                                                ]
                                        );
                                }
@@ -203,7 +200,7 @@ class Notifier implements INotifier {
         * @param ICloudId $cloudId
         * @return string
         */
-       protected function getDisplayName(ICloudId $cloudId) {
+       protected function getDisplayName(ICloudId $cloudId): string {
                $server = $cloudId->getRemote();
                $user = $cloudId->getUser();
                if (strpos($server, 'http://') === 0) {
@@ -213,17 +210,24 @@ class Notifier implements INotifier {
                }
 
                try {
+                       // contains protocol in the  ID
                        return $this->getDisplayNameFromContact($cloudId->getId());
                } catch (\OutOfBoundsException $e) {
                }
 
                try {
-                       $this->getDisplayNameFromContact($user . '@http://' . $server);
+                       // does not include protocol, as stored in addressbooks
+                       return $this->getDisplayNameFromContact($cloudId->getDisplayId());
                } catch (\OutOfBoundsException $e) {
                }
 
                try {
-                       $this->getDisplayNameFromContact($user . '@https://' . $server);
+                       return $this->getDisplayNameFromContact($user . '@http://' . $server);
+               } catch (\OutOfBoundsException $e) {
+               }
+
+               try {
+                       return $this->getDisplayNameFromContact($user . '@https://' . $server);
                } catch (\OutOfBoundsException $e) {
                }