Skip to content

Commit 1e60cdc

Browse files
Merge pull request #54508 from nextcloud/backport/54440/stable30
[stable30] fix(caldav): encode calendar URLs properly when formatting search results
2 parents 5b6b94a + 89dc3df commit 1e60cdc

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

apps/dav/lib/Search/EventsSearchProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected function getDavUrlForCalendarObject(
199199
[,, $principalId] = explode('/', $principalUri, 3);
200200

201201
return $this->urlGenerator->linkTo('', 'remote.php') . '/dav/calendars/'
202-
. $principalId . '/'
202+
. rawurlencode($principalId) . '/'
203203
. $calendarUri . '/'
204204
. $calendarObjectUri;
205205
}

apps/dav/tests/unit/Search/EventsSearchProviderTest.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,20 @@ public function testSearch(): void {
408408
$this->assertFalse($result2Data['rounded']);
409409
}
410410

411-
public function testGetDeepLinkToCalendarApp(): void {
411+
public static function provideDeepLinkData(): array {
412+
return [
413+
['principals/users/john.doe', 'bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M='],
414+
['principals/users/John Doe', 'bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvSm9obiUyMERvZS9mb28vYmFyLmljcw=='],
415+
];
416+
}
417+
418+
/**
419+
* @dataProvider provideDeepLinkData
420+
*/
421+
public function testGetDeepLinkToCalendarApp(
422+
string $principalUri,
423+
string $expectedBase64DavUrl,
424+
): void {
412425
$this->urlGenerator->expects($this->once())
413426
->method('linkTo')
414427
->with('', 'remote.php')
@@ -419,10 +432,14 @@ public function testGetDeepLinkToCalendarApp(): void {
419432
->willReturn('link-to-route-calendar/');
420433
$this->urlGenerator->expects($this->once())
421434
->method('getAbsoluteURL')
422-
->with('link-to-route-calendar/edit/bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M=')
435+
->with("link-to-route-calendar/edit/$expectedBase64DavUrl")
423436
->willReturn('absolute-url-to-route');
424437

425-
$actual = self::invokePrivate($this->provider, 'getDeepLinkToCalendarApp', ['principals/users/john.doe', 'foo', 'bar.ics']);
438+
$actual = self::invokePrivate($this->provider, 'getDeepLinkToCalendarApp', [
439+
$principalUri,
440+
'foo',
441+
'bar.ics',
442+
]);
426443

427444
$this->assertEquals('absolute-url-to-route', $actual);
428445
}

0 commit comments

Comments
 (0)