diff --git a/cassandane/Cassandane/Cyrus/Caldav.pm b/cassandane/Cassandane/Cyrus/Caldav.pm index 42e3e91c86..c21af31547 100644 --- a/cassandane/Cassandane/Cyrus/Caldav.pm +++ b/cassandane/Cassandane/Cyrus/Caldav.pm @@ -47,6 +47,7 @@ use Net::DAVTalk::XMLParser; use File::Basename; use Data::Dumper; use Text::VCardFast; +use Cwd qw(abs_path); use lib '.'; use base qw(Cassandane::Cyrus::TestCase); @@ -6031,4 +6032,44 @@ EOF $self->assert_not_null($valarms[0]{properties}{uid}); } +sub test_freebusy_overrides + :min_version_3_9 :needs_component_httpd +{ + my ($self) = @_; + + my $CalDAV = $self->{caldav}; + + my $ical = <Request('PUT', '/dav/calendars/user/cassandane/Default/test.ics', + $ical, 'Content-Type' => 'text/calendar'); + + my ($data, $errors) = $CalDAV->GetFreeBusy('Default'); + $self->assert_str_equals('2023-01-01T16:00:00', $data->[0]{start}); + $self->assert_str_equals('PT1H', $data->[0]{duration}); + $self->assert_str_equals('2023-12-31T16:00:00', $data->[1]{start}); + $self->assert_str_equals('PT2H', $data->[1]{duration}); + $self->assert_num_equals(2, scalar @$data); +} + 1; diff --git a/imap/ical_support.c b/imap/ical_support.c index 3204f1f67b..745488a717 100644 --- a/imap/ical_support.c +++ b/imap/ical_support.c @@ -1342,6 +1342,7 @@ icalrecurrenceset_get_utc_timespan(icalcomponent *ical, struct icalperiodtype span; icalcomponent *comp = icalcomponent_get_first_component(ical, kind); unsigned recurring = 0; + unsigned n_recurid = 0; /* Initialize span to be nothing */ span.start = icaltime_from_timet_with_zone(caldav_eternity, 0, NULL); @@ -1426,6 +1427,10 @@ icalrecurrenceset_get_utc_timespan(icalcomponent *ical, ptrarray_fini(&detached_rrules); } + /* Count recurrence-ids */ + if (icalcomponent_get_first_property(comp, ICAL_RECURRENCEID_PROPERTY)) + if (n_recurid < UINT_MAX) n_recurid++; + /* Check our dtstart and dtend against span */ if (icaltime_compare(period.start, span.start) < 0) memcpy(&span.start, &period.start, sizeof(struct icaltimetype)); @@ -1438,6 +1443,10 @@ icalrecurrenceset_get_utc_timespan(icalcomponent *ical, } while ((comp = icalcomponent_get_next_component(ical, kind))); + /* There might be more than one recurrence override without main component */ + if (!recurring && n_recurid >= 2) + recurring = 1; + if (is_recurring) *is_recurring = recurring; return span;