Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3746,7 +3746,6 @@ public function updateProperties($calendarId, $objectUri, $calendarData, $calend
if (!$this->db->supports4ByteText()) {
$value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value);
}
$value = mb_strcut($value, 0, 254);

$query->setParameter('name', $property->name);
$query->setParameter('parameter', null);
Expand All @@ -3761,7 +3760,7 @@ public function updateProperties($calendarId, $objectUri, $calendarData, $calend
foreach ($parameters as $key => $value) {
if (in_array($key, $indexedParametersForProperty, true)) {
// is this a shitty db?
if ($this->db->supports4ByteText()) {
if (!$this->db->supports4ByteText()) {
$value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value);
}

Expand Down
44 changes: 44 additions & 0 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,50 @@ public function testCalendarObjectsOperations(): void {
$this->assertCount(0, $calendarObjects);
}

public function testUpdatePropertiesHandlesFourByteIndexedParameters(): void {
$this->dispatcher->expects(self::any())->method('dispatchTyped');
$calendarId = $this->createTestCalendar();
$uri = static::getUniqueID('calobj');
$calData = <<<'EOD'
BEGIN:VCALENDAR
VERSION:2.0
PRODID:Nextcloud Calendar
BEGIN:VEVENT
UID:indexed-parameter-four-byte-test
DTSTAMP:20240101T000000Z
DTSTART:20240101T100000Z
DTEND:20240101T110000Z
ATTENDEE;CN=Attendee 🙈:mailto:attendee@example.com
ORGANIZER;CN=Organizer 🙈:mailto:organizer@example.com
END:VEVENT
END:VCALENDAR
EOD;
$this->backend->createCalendarObject($calendarId, $uri, $calData);
$object = $this->backend->getCalendarObject($calendarId, $uri);
self::assertNotNull($object);

$supported = $this->db->supports4ByteText();
$expectedValues = [
'ATTENDEE' => 'Attendee ' . ($supported ? '🙈' : "\u{FFFD}"),
'ORGANIZER' => 'Organizer ' . ($supported ? '🙈' : "\u{FFFD}"),
];

foreach ($expectedValues as $property => $expectedValue) {
$query = $this->db->getQueryBuilder();
$result = $query->select('value')
->from('calendarobjects_props')
->where($query->expr()->eq('objectid', $query->createNamedParameter((int)$object['id'])))
->andWhere($query->expr()->eq('name', $query->createNamedParameter($property)))
->andWhere($query->expr()->eq('parameter', $query->createNamedParameter('CN')))
->setMaxResults(1)
->executeQuery();
$indexedValue = $result->fetchOne();
$result->closeCursor();

self::assertSame($expectedValue, $indexedValue, "$property CN index value");
}
}

public function testMultipleCalendarObjectsWithSameUID(): void {
$this->expectException(UidConflict::class);
$this->expectExceptionMessage('Calendar object with uid already exists in this calendar collection.');
Expand Down
Loading