diff options
author | Joas Schilling <coding@schilljs.com> | 2017-08-14 14:35:28 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-08-16 13:57:30 +0200 |
commit | bd80121fc6f6d917bdd7b30b511ebaea3995a650 (patch) | |
tree | a5999c7bade6ccdeeca7d48fa268b1515813e1fb /apps/files_sharing | |
parent | 7913d33de9509f0ad16319c678189f91f3073a8f (diff) | |
download | nextcloud-server-bd80121fc6f6d917bdd7b30b511ebaea3995a650.tar.gz nextcloud-server-bd80121fc6f6d917bdd7b30b511ebaea3995a650.zip |
Catch exceptions on error of cloud id resolution
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareesAPIController.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 3e0c01b342e..33341d20b5c 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -335,7 +335,12 @@ class ShareesAPIController extends OCSController { } $lowerSearch = strtolower($search); foreach ($cloudIds as $cloudId) { - list(, $serverUrl) = $this->splitUserRemote($cloudId); + try { + list(, $serverUrl) = $this->splitUserRemote($cloudId); + } catch (\InvalidArgumentException $e) { + continue; + } + if (strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) { if (strtolower($cloudId) === $lowerSearch) { $result['exactIdMatch'] = true; @@ -386,14 +391,14 @@ class ShareesAPIController extends OCSController { * * @param string $address federated share address * @return array [user, remoteURL] - * @throws \Exception + * @throws \InvalidArgumentException */ public function splitUserRemote($address) { try { $cloudId = $this->cloudIdManager->resolveCloudId($address); return [$cloudId->getUser(), $cloudId->getRemote()]; } catch (\InvalidArgumentException $e) { - throw new \Exception('Invalid Federated Cloud ID', 0, $e); + throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e); } } @@ -610,7 +615,12 @@ class ShareesAPIController extends OCSController { if (isset($contact['isLocalSystemBook'])) { if ($exactEmailMatch) { - $cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]); + try { + $cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]); + } catch (\InvalidArgumentException $e) { + continue; + } + if (!$this->hasUserInResult($cloud->getUser())) { $this->result['exact']['users'][] = [ 'label' => $contact['FN'] . " ($emailAddress)", @@ -622,8 +632,14 @@ class ShareesAPIController extends OCSController { } return ['results' => [], 'exact' => [], 'exactIdMatch' => true]; } + if ($this->shareeEnumeration) { - $cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]); + try { + $cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]); + } catch (\InvalidArgumentException $e) { + continue; + } + if (!$this->hasUserInResult($cloud->getUser())) { $this->result['users'][] = [ 'label' => $contact['FN'] . " ($emailAddress)", |