diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-06-18 09:21:06 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-06-22 15:25:23 +0200 |
commit | d38a378b8cc8d13e6459ccb4cfbc8a8bbe1f8428 (patch) | |
tree | 703cc3a64712860e919913d33ea883405927de48 /lib/private/share/helper.php | |
parent | a88b370dc84c4dfdcab7a128900829fbe8204ca7 (diff) | |
download | nextcloud-server-d38a378b8cc8d13e6459ccb4cfbc8a8bbe1f8428.tar.gz nextcloud-server-d38a378b8cc8d13e6459ccb4cfbc8a8bbe1f8428.zip |
make sure that we split username and server address at the first '@' from the right to allow usernames containing '@'
Diffstat (limited to 'lib/private/share/helper.php')
-rw-r--r-- | lib/private/share/helper.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php index 65167dd7549..d88c4bcbfc2 100644 --- a/lib/private/share/helper.php +++ b/lib/private/share/helper.php @@ -27,6 +27,8 @@ namespace OC\Share; +use OC\Share\Exceptions\InvalidFederatedCloudIdException; + class Helper extends \OC\Share\Constants { /** @@ -244,4 +246,24 @@ class Helper extends \OC\Share\Constants { return rtrim($shareWith, '/'); } + + /** + * split user and remote from federated cloud id + * + * @param string $id + * @return array + * @throws InvalidFederatedCloudIdException + */ + public static function splitUserRemote($id) { + $pos = strrpos($id, '@'); + if ($pos !== false) { + $user = substr($id, 0, $pos); + $remote = substr($id, $pos + 1); + if (!empty($user) && !empty($remote)) { + return array($user, $remote); + } + } + + throw new InvalidFederatedCloudIdException('invalid Federated Cloud ID'); + } } |