Skip to content

Commit c2437eb

Browse files
Merge pull request #54440 from nextcloud/fix/caldav/search-uid-urlencode
2 parents 74d9649 + fa80a61 commit c2437eb

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-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: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\Search\ISearchQuery;
1919
use OCP\Search\SearchResult;
2020
use OCP\Search\SearchResultEntry;
21+
use PHPUnit\Framework\Attributes\DataProvider;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223
use Sabre\VObject\Reader;
2324
use Test\TestCase;
@@ -399,7 +400,18 @@ public function testSearch(): void {
399400
$this->assertFalse($result2Data['rounded']);
400401
}
401402

402-
public function testGetDeepLinkToCalendarApp(): void {
403+
public static function provideDeepLinkData(): array {
404+
return [
405+
['principals/users/john.doe', 'bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M='],
406+
['principals/users/John Doe', 'bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvSm9obiUyMERvZS9mb28vYmFyLmljcw=='],
407+
];
408+
}
409+
410+
#[DataProvider('provideDeepLinkData')]
411+
public function testGetDeepLinkToCalendarApp(
412+
string $principalUri,
413+
string $expectedBase64DavUrl,
414+
): void {
403415
$this->urlGenerator->expects($this->once())
404416
->method('linkTo')
405417
->with('', 'remote.php')
@@ -410,10 +422,14 @@ public function testGetDeepLinkToCalendarApp(): void {
410422
->willReturn('link-to-route-calendar/');
411423
$this->urlGenerator->expects($this->once())
412424
->method('getAbsoluteURL')
413-
->with('link-to-route-calendar/edit/bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M=')
425+
->with("link-to-route-calendar/edit/$expectedBase64DavUrl")
414426
->willReturn('absolute-url-to-route');
415427

416-
$actual = self::invokePrivate($this->provider, 'getDeepLinkToCalendarApp', ['principals/users/john.doe', 'foo', 'bar.ics']);
428+
$actual = self::invokePrivate($this->provider, 'getDeepLinkToCalendarApp', [
429+
$principalUri,
430+
'foo',
431+
'bar.ics',
432+
]);
417433

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

0 commit comments

Comments
 (0)