Skip to content

Commit b79e34c

Browse files
committed
fix check for Cloud ID, missing return statements, wrong param use
Signed-off-by: Arthur Schiwon <[email protected]>
1 parent 2698e9e commit b79e34c

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,9 @@ public function search($addressBookId, $pattern, $searchProperties, $options = [
974974
continue;
975975
}
976976

977-
if ($property === 'CLOUD' && preg_match('/[^a-zA-Z0-9 _.@\-\']/', $pattern) === 1) {
978-
// There can be no chars in cloud ids which are not valid for user ids
977+
if ($property === 'CLOUD' && preg_match('/[^a-zA-Z0-9 :_.@\/\-\']/', $pattern) === 1) {
978+
// There can be no chars in cloud ids which are not valid for user ids plus :/
979+
// worst case: CA61590A-BBBC-423E-84AF-E6DF01455A53@https://my.nxt/srv/
979980
continue;
980981
}
981982
}

apps/federatedfilesharing/lib/Notifier.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ public function prepare(INotification $notification, string $languageCode): INot
107107
);
108108

109109
$initiator = $params[0];
110-
$initiatorDisplay = isset($params[3]) ? $params[3] : null;
111110
$owner = $params[1];
112-
$ownerDisplay = isset($params[4]) ? $params[4] : null;
113111

114112
$notification->setRichSubject(
115113
$l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'),
@@ -119,8 +117,8 @@ public function prepare(INotification $notification, string $languageCode): INot
119117
'id' => $notification->getObjectId(),
120118
'name' => $params[2],
121119
],
122-
'user' => $this->createRemoteUser($initiator, $initiatorDisplay),
123-
'behalf' => $this->createRemoteUser($owner, $ownerDisplay),
120+
'user' => $this->createRemoteUser($initiator),
121+
'behalf' => $this->createRemoteUser($owner),
124122
]
125123
);
126124
} else {
@@ -129,7 +127,6 @@ public function prepare(INotification $notification, string $languageCode): INot
129127
);
130128

131129
$owner = $params[0];
132-
$ownerDisplay = isset($params[3]) ? $params[3] : null;
133130

134131
$notification->setRichSubject(
135132
$l->t('You received {share} as a remote share from {user}'),
@@ -139,7 +136,7 @@ public function prepare(INotification $notification, string $languageCode): INot
139136
'id' => $notification->getObjectId(),
140137
'name' => $params[2],
141138
],
142-
'user' => $this->createRemoteUser($owner, $ownerDisplay),
139+
'user' => $this->createRemoteUser($owner),
143140
]
144141
);
145142
}
@@ -203,7 +200,7 @@ protected function createRemoteUser($cloudId, $displayName = null) {
203200
* @param ICloudId $cloudId
204201
* @return string
205202
*/
206-
protected function getDisplayName(ICloudId $cloudId) {
203+
protected function getDisplayName(ICloudId $cloudId): string {
207204
$server = $cloudId->getRemote();
208205
$user = $cloudId->getUser();
209206
if (strpos($server, 'http://') === 0) {
@@ -213,17 +210,24 @@ protected function getDisplayName(ICloudId $cloudId) {
213210
}
214211

215212
try {
213+
// contains protocol in the ID
216214
return $this->getDisplayNameFromContact($cloudId->getId());
217215
} catch (\OutOfBoundsException $e) {
218216
}
219217

220218
try {
221-
$this->getDisplayNameFromContact($user . '@http://' . $server);
219+
// does not include protocol, as stored in addressbooks
220+
return $this->getDisplayNameFromContact($cloudId->getDisplayId());
222221
} catch (\OutOfBoundsException $e) {
223222
}
224223

225224
try {
226-
$this->getDisplayNameFromContact($user . '@https://' . $server);
225+
return $this->getDisplayNameFromContact($user . '@http://' . $server);
226+
} catch (\OutOfBoundsException $e) {
227+
}
228+
229+
try {
230+
return $this->getDisplayNameFromContact($user . '@https://' . $server);
227231
} catch (\OutOfBoundsException $e) {
228232
}
229233

0 commit comments

Comments
 (0)