Skip to content

Commit 3100599

Browse files
committed
replace @ with ~ in urls
1 parent b4437c5 commit 3100599

File tree

6 files changed

+44
-45
lines changed

6 files changed

+44
-45
lines changed

solid/appinfo/routes.php

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* it's instantiated in there
1616
*/
1717

18-
1918
$routes = [
2019
['name' => 'page#approval', 'url' => '/sharing/{clientId}', 'verb' => 'GET'],
2120
['name' => 'page#handleRevoke', 'url' => '/revoke/{clientId}', 'verb' => 'DELETE'],
@@ -44,47 +43,47 @@
4443
];
4544

4645
$userIdRoutes = [
47-
['name' => 'page#profile', 'url' => '/@{userId}/', 'verb' => 'GET'],
48-
49-
['name' => 'profile#handleGet', 'url' => '/@{userId}/profile{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ],
50-
['name' => 'profile#handlePut', 'url' => '/@{userId}/profile{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ],
51-
['name' => 'profile#handlePatch', 'url' => '/@{userId}/profile{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ],
52-
['name' => 'profile#handleHead', 'url' => '/@{userId}/profile{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ],
53-
54-
['name' => 'storage#handleGet', 'url' => '/@{userId}/storage{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ],
55-
['name' => 'storage#handlePost', 'url' => '/@{userId}/storage{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ],
56-
['name' => 'storage#handlePut', 'url' => '/@{userId}/storage{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ],
57-
['name' => 'storage#handleDelete', 'url' => '/@{userId}/storage{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ],
58-
['name' => 'storage#handlePatch', 'url' => '/@{userId}/storage{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ],
59-
['name' => 'storage#handleHead', 'url' => '/@{userId}/storage{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ],
60-
61-
['name' => 'calendar#handleGet', 'url' => '/@{userId}/calendar{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ],
62-
['name' => 'calendar#handlePost', 'url' => '/@{userId}/calendar{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ],
63-
['name' => 'calendar#handlePut', 'url' => '/@{userId}/calendar{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ],
64-
['name' => 'calendar#handleDelete', 'url' => '/@{userId}/calendar{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ],
65-
['name' => 'calendar#handlePatch', 'url' => '/@{userId}/calendar{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ],
66-
['name' => 'calendar#handleHead', 'url' => '/@{userId}/calendar{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ],
67-
68-
['name' => 'contacts#handleGet', 'url' => '/@{userId}/contacts{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ],
69-
['name' => 'contacts#handlePost', 'url' => '/@{userId}/contacts{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ],
70-
['name' => 'contacts#handlePut', 'url' => '/@{userId}/contacts{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ],
71-
['name' => 'contacts#handleDelete', 'url' => '/@{userId}/contacts{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ],
72-
['name' => 'contacts#handlePatch', 'url' => '/@{userId}/contacts{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ],
73-
['name' => 'contacts#handleHead', 'url' => '/@{userId}/contacts{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ],
46+
['name' => 'page#profile', 'url' => '/~{userId}/', 'verb' => 'GET'],
47+
48+
['name' => 'profile#handleGet', 'url' => '/~{userId}/profile{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ],
49+
['name' => 'profile#handlePut', 'url' => '/~{userId}/profile{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ],
50+
['name' => 'profile#handlePatch', 'url' => '/~{userId}/profile{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ],
51+
['name' => 'profile#handleHead', 'url' => '/~{userId}/profile{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ],
52+
53+
['name' => 'storage#handleGet', 'url' => '/~{userId}/storage{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ],
54+
['name' => 'storage#handlePost', 'url' => '/~{userId}/storage{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ],
55+
['name' => 'storage#handlePut', 'url' => '/~{userId}/storage{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ],
56+
['name' => 'storage#handleDelete', 'url' => '/~{userId}/storage{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ],
57+
['name' => 'storage#handlePatch', 'url' => '/~{userId}/storage{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ],
58+
['name' => 'storage#handleHead', 'url' => '/~{userId}/storage{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ],
59+
60+
['name' => 'calendar#handleGet', 'url' => '/~{userId}/calendar{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ],
61+
['name' => 'calendar#handlePost', 'url' => '/~{userId}/calendar{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ],
62+
['name' => 'calendar#handlePut', 'url' => '/~{userId}/calendar{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ],
63+
['name' => 'calendar#handleDelete', 'url' => '/~{userId}/calendar{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ],
64+
['name' => 'calendar#handlePatch', 'url' => '/~{userId}/calendar{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ],
65+
['name' => 'calendar#handleHead', 'url' => '/~{userId}/calendar{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ],
66+
67+
['name' => 'contacts#handleGet', 'url' => '/~{userId}/contacts{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], ],
68+
['name' => 'contacts#handlePost', 'url' => '/~{userId}/contacts{path}', 'verb' => 'POST', 'requirements' => ['path' => '.+'], ],
69+
['name' => 'contacts#handlePut', 'url' => '/~{userId}/contacts{path}', 'verb' => 'PUT', 'requirements' => ['path' => '.+'], ],
70+
['name' => 'contacts#handleDelete', 'url' => '/~{userId}/contacts{path}', 'verb' => 'DELETE', 'requirements' => ['path' => '.+'], ],
71+
['name' => 'contacts#handlePatch', 'url' => '/~{userId}/contacts{path}', 'verb' => 'PATCH', 'requirements' => ['path' => '.+'], ],
72+
['name' => 'contacts#handleHead', 'url' => '/~{userId}/contacts{path}', 'verb' => 'HEAD', 'requirements' => ['path' => '.+'], ],
7473
];
7574

7675
// @TODO: All routes NOT generated by the UrlGenerator ANYWHERE in the code need to be checked!
7776

7877
if (Application::$userSubDomainsEnabled) {
7978
$userIdRoutes = array_map(function ($route) {
8079
if ($route['name'] === 'page#profile') {
81-
// The profile route should be `/me` instead of `/@{userId}/`
80+
// The profile route should be `/me` instead of `/~{userId}/`
8281
$route['url'] = '/me';
8382
} else {
8483
// When UserSubDomains are enabled, all routes that start with
85-
// `/@{userId}/` should just be `/`, as the userId is present
84+
// `/~{userId}/` should just be `/`, as the userId is present
8685
// in the subdomain.
87-
$route['url'] = preg_replace('#^/@{userId}/#', '/', $route['url']);
86+
$route['url'] = preg_replace('#^/~{userId}/#', '/', $route['url']);
8887
}
8988

9089
// The required userId is set to the userId from the subdomain

solid/lib/Controller/CalendarController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ public function handlePut() { // $userId, $path) {
190190
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
191191

192192
// because we got here, the request uri should look like:
193-
// /index.php/apps/solid/@{userId}/storage{path}
194-
$pathInfo = explode("@", $_SERVER['REQUEST_URI']);
193+
// /index.php/apps/solid/~{userId}/storage{path}
194+
$pathInfo = explode("~", $_SERVER['REQUEST_URI']);
195195
$pathInfo = explode("/", $pathInfo[1], 2);
196196
$userId = $pathInfo[0];
197197
$path = $pathInfo[1];

solid/lib/Controller/ContactsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ public function handlePut() { // $userId, $path) {
191191
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
192192

193193
// because we got here, the request uri should look like:
194-
// /index.php/apps/solid/@{userId}/storage{path}
195-
$pathInfo = explode("@", $_SERVER['REQUEST_URI']);
194+
// /index.php/apps/solid/~{userId}/storage{path}
195+
$pathInfo = explode("~", $_SERVER['REQUEST_URI']);
196196
$pathInfo = explode("/", $pathInfo[1], 2);
197197
$userId = $pathInfo[0];
198198
$path = $pathInfo[1];

solid/lib/Controller/ProfileController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ public function handlePut() { // $userId, $path) {
209209
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
210210

211211
// because we got here, the request uri should look like:
212-
// /index.php/apps/solid/@{userId}/storage{path}
213-
$pathInfo = explode("@", $_SERVER['REQUEST_URI']);
212+
// /index.php/apps/solid/~{userId}/storage{path}
213+
$pathInfo = explode("~", $_SERVER['REQUEST_URI']);
214214
$pathInfo = explode("/", $pathInfo[1], 2);
215215
$userId = $pathInfo[0];
216216
$path = $pathInfo[1];

solid/lib/Controller/SolidWebhookController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ private function initializeStorage($userId) {
150150
}
151151

152152
private function parseTopic($topic) {
153-
// topic = https://nextcloud.server/solid/@alice/storage/foo/bar
153+
// topic = https://nextcloud.server/solid/~alice/storage/foo/bar
154154
$appBaseUrl = $this->getAppBaseUrl(); // https://nextcloud.server/solid/
155-
$internalUrl = str_replace($appBaseUrl, '', $topic); // @alice/storage/foo/bar
155+
$internalUrl = str_replace($appBaseUrl, '', $topic); // ~alice/storage/foo/bar
156156
$pathicles = explode("/", $internalUrl);
157-
$userId = $pathicles[0]; // @alice
158-
$userId = preg_replace("/^@/", "", $userId); // alice
159-
$storageUrl = $this->getStorageUrl($userId); // https://nextcloud.server/solid/@alice/storage/
157+
$userId = $pathicles[0]; // ~alice
158+
$userId = preg_replace("/^~/", "", $userId); // alice
159+
$storageUrl = $this->getStorageUrl($userId); // https://nextcloud.server/solid/~alice/storage/
160160
$storagePath = str_replace($storageUrl, '/', $topic); // /foo/bar
161161
return array(
162162
"userId" => $userId,
@@ -182,7 +182,7 @@ private function createGetRequest($topic) {
182182
}
183183

184184
private function checkReadAccess($topic) {
185-
// split out $topic into $userId and $path https://nextcloud.server/solid/@alice/storage/foo/bar
185+
// split out $topic into $userId and $path https://nextcloud.server/solid/~alice/storage/foo/bar
186186
// - userId in this case is the pod owner (not the one doing the request). (alice)
187187
// - path is the path within the storage pod (/foo/bar)
188188
$target = $this->parseTopic($topic);

solid/lib/Controller/StorageController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ public function handlePut() { // $userId, $path) {
380380
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
381381

382382
// because we got here, the request uri should look like:
383-
// /index.php/apps/solid/@{userId}/storage{path}
384-
$pathInfo = explode("@", $_SERVER['REQUEST_URI']);
383+
// /index.php/apps/solid/~{userId}/storage{path}
384+
$pathInfo = explode("~", $_SERVER['REQUEST_URI']);
385385
$pathInfo = explode("/", $pathInfo[1], 2);
386386
$userId = $pathInfo[0];
387387
$path = $pathInfo[1];

0 commit comments

Comments
 (0)