clean cloud ids
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
ae66cf8d37
commit
f6cd5200a2
|
@ -171,7 +171,7 @@ class FederatedShareProvider implements IShareProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$share->setSharedWith(rtrim($cloudId->getId(), '/'));
|
$share->setSharedWith($cloudId->getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$remoteShare = $this->getShareFromExternalShareTable($share);
|
$remoteShare = $this->getShareFromExternalShareTable($share);
|
||||||
|
|
|
@ -34,7 +34,7 @@ class CloudIdManager implements ICloudIdManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the first character that is not allowed in user names
|
// Find the first character that is not allowed in user names
|
||||||
$id = str_replace('\\', '/', $cloudId);
|
$id = $this->fixRemoteURL($cloudId);
|
||||||
$posSlash = strpos($id, '/');
|
$posSlash = strpos($id, '/');
|
||||||
$posColon = strpos($id, ':');
|
$posColon = strpos($id, ':');
|
||||||
|
|
||||||
|
@ -58,9 +58,8 @@ class CloudIdManager implements ICloudIdManager {
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
$user = substr($id, 0, $pos);
|
$user = substr($id, 0, $pos);
|
||||||
$remote = substr($id, $pos + 1);
|
$remote = substr($id, $pos + 1);
|
||||||
$remote = $this->fixRemoteURL($remote);
|
|
||||||
if (!empty($user) && !empty($remote)) {
|
if (!empty($user) && !empty($remote)) {
|
||||||
return new CloudId($cloudId, $user, $remote);
|
return new CloudId($id, $user, $remote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new \InvalidArgumentException('Invalid cloud id');
|
throw new \InvalidArgumentException('Invalid cloud id');
|
||||||
|
|
|
@ -35,12 +35,11 @@ class CloudIdManagerTest extends TestCase {
|
||||||
|
|
||||||
public function cloudIdProvider() {
|
public function cloudIdProvider() {
|
||||||
return [
|
return [
|
||||||
['test@example.com', 'test', 'example.com'],
|
['test@example.com', 'test', 'example.com', 'test@example.com'],
|
||||||
['test@example.com/cloud', 'test', 'example.com/cloud'],
|
['test@example.com/cloud', 'test', 'example.com/cloud', 'test@example.com/cloud'],
|
||||||
['test@example.com/cloud/', 'test', 'example.com/cloud'],
|
['test@example.com/cloud/', 'test', 'example.com/cloud', 'test@example.com/cloud'],
|
||||||
['test@example.com/cloud/index.php', 'test', 'example.com/cloud'],
|
['test@example.com/cloud/index.php', 'test', 'example.com/cloud', 'test@example.com/cloud'],
|
||||||
['test@example.com@example.com', 'test@example.com', 'example.com'],
|
['test@example.com@example.com', 'test@example.com', 'example.com', 'test@example.com@example.com'],
|
||||||
['test@example.com@example.com', 'test@example.com', 'example.com'],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +50,12 @@ class CloudIdManagerTest extends TestCase {
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $remote
|
* @param string $remote
|
||||||
*/
|
*/
|
||||||
public function testResolveCloudId($cloudId, $user, $remote) {
|
public function testResolveCloudId($cloudId, $user, $remote, $cleanId) {
|
||||||
$cloudId = $this->cloudIdManager->resolveCloudId($cloudId);
|
$cloudId = $this->cloudIdManager->resolveCloudId($cloudId);
|
||||||
|
|
||||||
$this->assertEquals($user, $cloudId->getUser());
|
$this->assertEquals($user, $cloudId->getUser());
|
||||||
$this->assertEquals($remote, $cloudId->getRemote());
|
$this->assertEquals($remote, $cloudId->getRemote());
|
||||||
|
$this->assertEquals($cleanId, $cloudId->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invalidCloudIdProvider() {
|
public function invalidCloudIdProvider() {
|
||||||
|
|
Loading…
Reference in New Issue