Skip to content

Commit 9d58868

Browse files
Olenclaude
andcommitted
fix(dav): handle content line folding in DTSTAMP regex
Update regex to match DTSTAMP with parameters (DTSTAMP;TZID=...) and handle RFC 5545 content line folding where long lines are split with CRLF followed by a space or tab. Signed-off-by: Olen <regopa@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: olen <ola@nytt.no>
1 parent 36fdb9a commit 9d58868

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function refreshSubscription(string $principalUri, string $uri) {
117117
// to the current time on every feed request per RFC 5545, causing
118118
// every event to appear modified on every refresh.
119119
// DTSTAMP is kept in the stored data as it is a required property.
120-
$sObjectForEtag = preg_replace('/^DTSTAMP:.*\r?\n/m', '', $sObject);
120+
$sObjectForEtag = preg_replace('/^DTSTAMP[;:].*\r?\n([ \t].*\r?\n)*/m', '', $sObject);
121121
$etag = md5($sObjectForEtag);
122122

123123
// No existing object with this UID, create it

apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ public function testDtstampChangeDoesNotTriggerUpdate(): void {
493493
->willReturn(['data' => $stream, 'format' => 'ical']);
494494

495495
// The stored etag was computed from the DTSTAMP-stripped serialization
496-
$existingEtag = md5(preg_replace('/^DTSTAMP:.*\r?\n/m', '', $body));
496+
$existingEtag = md5(preg_replace('/^DTSTAMP[;:].*\r?\n([ \t].*\r?\n)*/m', '', $body));
497497

498498
$this->caldavBackend->expects(self::once())
499499
->method('getLimitedCalendarObjects')
@@ -528,7 +528,7 @@ public function testDtstampChangeDoesNotTriggerUpdate(): void {
528528
public static function identicalDataProvider(): array {
529529
$icalBody = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject " . VObject\Version::VERSION . "//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
530530
// Etag is computed from DTSTAMP-stripped serialization
531-
$etag = md5(preg_replace('/^DTSTAMP:.*\r?\n/m', '', $icalBody));
531+
$etag = md5(preg_replace('/^DTSTAMP[;:].*\r?\n([ \t].*\r?\n)*/m', '', $icalBody));
532532

533533
return [
534534
[

0 commit comments

Comments
 (0)