diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2024-06-20 10:56:27 +0200 |
---|---|---|
committer | Richard Steinmetz <richard@steinmetz.cloud> | 2024-06-20 10:56:27 +0200 |
commit | df28c04a8f49dca0454169ad3c11b84b092dc8ff (patch) | |
tree | ff06804788d6ec6d9be6d36a5b32ec78a74301be /apps/dav/lib/CalDAV | |
parent | 392ee62981229f762daaea4032de5f5cb6344d16 (diff) | |
download | nextcloud-server-df28c04a8f49dca0454169ad3c11b84b092dc8ff.tar.gz nextcloud-server-df28c04a8f49dca0454169ad3c11b84b092dc8ff.zip |
fix(caldav): encode calendar URIs with umlauts for activities
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'apps/dav/lib/CalDAV')
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Provider/Event.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Event.php b/apps/dav/lib/CalDAV/Activity/Provider/Event.php index 45d4f731e20..959c0a815dd 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Event.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Event.php @@ -76,14 +76,15 @@ class Event extends Base { // The calendar app needs to be manually loaded for the routes to be loaded OC_App::loadApp('calendar'); $linkData = $eventData['link']; + $calendarUri = $this->urlencodeLowerHex($linkData['calendar_uri']); if ($affectedUser === $linkData['owner']) { - $objectId = base64_encode($this->url->getWebroot() . '/remote.php/dav/calendars/' . $linkData['owner'] . '/' . $linkData['calendar_uri'] . '/' . $linkData['object_uri']); + $objectId = base64_encode($this->url->getWebroot() . '/remote.php/dav/calendars/' . $linkData['owner'] . '/' . $calendarUri . '/' . $linkData['object_uri']); } else { // Can't use the "real" owner and calendar names here because we create a custom // calendar for incoming shares with the name "<calendar>_shared_by_<sharer>". // Hack: Fix the link by generating it for the incoming shared calendar instead, // as seen from the affected user. - $objectId = base64_encode($this->url->getWebroot() . '/remote.php/dav/calendars/' . $affectedUser . '/' . $linkData['calendar_uri'] . '_shared_by_' . $linkData['owner'] . '/' . $linkData['object_uri']); + $objectId = base64_encode($this->url->getWebroot() . '/remote.php/dav/calendars/' . $affectedUser . '/' . $calendarUri . '_shared_by_' . $linkData['owner'] . '/' . $linkData['object_uri']); } $link = [ 'view' => 'dayGridMonth', @@ -241,4 +242,16 @@ class Event extends Base { } return $parameter; } + + /** + * Return urlencoded string but with lower cased hex sequences. + * The remaining casing will be untouched. + */ + private function urlencodeLowerHex(string $raw): string { + return preg_replace_callback( + '/%[0-9A-F]{2}/', + static fn (array $matches) => strtolower($matches[0]), + urlencode($raw), + ); + } } |