fix(caldav): encode calendar URLs properly when formatting search results

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
pull/54440/head
Richard Steinmetz 2025-08-15 14:45:49 +07:00
parent 7bb0e0de7a
commit fa80a6199d
No known key found for this signature in database
GPG Key ID: 27137D9E7D273FB2
2 changed files with 20 additions and 4 deletions

@ -199,7 +199,7 @@ class EventsSearchProvider extends ACalendarSearchProvider implements IFiltering
[,, $principalId] = explode('/', $principalUri, 3);
return $this->urlGenerator->linkTo('', 'remote.php') . '/dav/calendars/'
. $principalId . '/'
. rawurlencode($principalId) . '/'
. $calendarUri . '/'
. $calendarObjectUri;
}

@ -18,6 +18,7 @@ use OCP\Search\IFilter;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
use OCP\Search\SearchResultEntry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Sabre\VObject\Reader;
use Test\TestCase;
@ -399,7 +400,18 @@ class EventsSearchProviderTest extends TestCase {
$this->assertFalse($result2Data['rounded']);
}
public function testGetDeepLinkToCalendarApp(): void {
public static function provideDeepLinkData(): array {
return [
['principals/users/john.doe', 'bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M='],
['principals/users/John Doe', 'bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvSm9obiUyMERvZS9mb28vYmFyLmljcw=='],
];
}
#[DataProvider('provideDeepLinkData')]
public function testGetDeepLinkToCalendarApp(
string $principalUri,
string $expectedBase64DavUrl,
): void {
$this->urlGenerator->expects($this->once())
->method('linkTo')
->with('', 'remote.php')
@ -410,10 +422,14 @@ class EventsSearchProviderTest extends TestCase {
->willReturn('link-to-route-calendar/');
$this->urlGenerator->expects($this->once())
->method('getAbsoluteURL')
->with('link-to-route-calendar/edit/bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M=')
->with("link-to-route-calendar/edit/$expectedBase64DavUrl")
->willReturn('absolute-url-to-route');
$actual = self::invokePrivate($this->provider, 'getDeepLinkToCalendarApp', ['principals/users/john.doe', 'foo', 'bar.ics']);
$actual = self::invokePrivate($this->provider, 'getDeepLinkToCalendarApp', [
$principalUri,
'foo',
'bar.ics',
]);
$this->assertEquals('absolute-url-to-route', $actual);
}