Skip to content

Commit 8b1abc0

Browse files
st3inybackportbot[bot]
authored andcommitted
fix(caldav): encode calendar URLs properly when formatting search results
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud> [skip ci]
1 parent 9e754ca commit 8b1abc0

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-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: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,18 @@ 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+
#[DataProvider('provideDeepLinkData')]
419+
public function testGetDeepLinkToCalendarApp(
420+
string $principalUri,
421+
string $expectedBase64DavUrl,
422+
): void {
412423
$this->urlGenerator->expects($this->once())
413424
->method('linkTo')
414425
->with('', 'remote.php')
@@ -419,10 +430,14 @@ public function testGetDeepLinkToCalendarApp(): void {
419430
->willReturn('link-to-route-calendar/');
420431
$this->urlGenerator->expects($this->once())
421432
->method('getAbsoluteURL')
422-
->with('link-to-route-calendar/edit/bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M=')
433+
->with("link-to-route-calendar/edit/$expectedBase64DavUrl")
423434
->willReturn('absolute-url-to-route');
424435

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

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

0 commit comments

Comments
 (0)