Skip to content

Commit a149d6d

Browse files
committed
icalrecur: Ignore time-related BY* if DTSTART is date-only.
1 parent 795de36 commit a149d6d

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/libical/icalrecur.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -756,26 +756,27 @@ static struct recur_map
756756
const char *str;
757757
size_t offset;
758758
int limit;
759+
int isTime;
759760
} recur_map[] = {
760761
{ ";BYSECOND=", offsetof(struct icalrecurrencetype, by_second),
761-
ICAL_BY_SECOND_SIZE - 1 },
762+
ICAL_BY_SECOND_SIZE - 1, 1 },
762763
{ ";BYMINUTE=", offsetof(struct icalrecurrencetype, by_minute),
763-
ICAL_BY_MINUTE_SIZE - 1 },
764+
ICAL_BY_MINUTE_SIZE - 1, 1 },
764765
{ ";BYHOUR=", offsetof(struct icalrecurrencetype, by_hour),
765-
ICAL_BY_HOUR_SIZE - 1 },
766+
ICAL_BY_HOUR_SIZE - 1, 1 },
766767
{ ";BYDAY=", offsetof(struct icalrecurrencetype, by_day),
767-
ICAL_BY_DAY_SIZE - 1 },
768+
ICAL_BY_DAY_SIZE - 1, 0 },
768769
{ ";BYMONTHDAY=", offsetof(struct icalrecurrencetype, by_month_day),
769-
ICAL_BY_MONTHDAY_SIZE - 1 },
770+
ICAL_BY_MONTHDAY_SIZE - 1, 0 },
770771
{ ";BYYEARDAY=", offsetof(struct icalrecurrencetype, by_year_day),
771-
ICAL_BY_YEARDAY_SIZE - 1 },
772+
ICAL_BY_YEARDAY_SIZE - 1, 0 },
772773
{ ";BYWEEKNO=", offsetof(struct icalrecurrencetype, by_week_no),
773-
ICAL_BY_WEEKNO_SIZE - 1 },
774+
ICAL_BY_WEEKNO_SIZE - 1, 0 },
774775
{ ";BYMONTH=", offsetof(struct icalrecurrencetype, by_month),
775-
ICAL_BY_MONTH_SIZE - 1 },
776+
ICAL_BY_MONTH_SIZE - 1, 0 },
776777
{ ";BYSETPOS=", offsetof(struct icalrecurrencetype, by_set_pos),
777-
ICAL_BY_SETPOS_SIZE - 1 },
778-
{ 0, 0, 0 }
778+
ICAL_BY_SETPOS_SIZE - 1, 0 },
779+
{ 0, 0, 0, 0 }
779780
};
780781

781782
char *icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
@@ -1041,7 +1042,15 @@ static void setup_defaults(icalrecur_iterator *impl,
10411042
{
10421043
icalrecurrencetype_frequency freq = impl->rule.freq;
10431044

1044-
if (expand_map[freq].map[byrule] == EXPAND) {
1045+
if (impl->dtstart.is_date && recur_map[byrule].isTime) {
1046+
// The BYSECOND, BYMINUTE and BYHOUR rule parts MUST NOT be specified
1047+
// when the associated "DTSTART" property has a DATE value type.
1048+
// These rule parts MUST be ignored in RECUR value that violate the
1049+
// above requirement (e.g., generated by applications that pre-date
1050+
// this revision of iCalendar).
1051+
impl->by_ptrs[byrule][0] = 0;
1052+
impl->by_ptrs[byrule][1] = ICAL_RECURRENCE_ARRAY_MAX;
1053+
} else if (expand_map[freq].map[byrule] == EXPAND) {
10451054

10461055
/* Re-write the BY rule arrays with data from the DTSTART time so
10471056
we don't have to explicitly deal with DTSTART */

0 commit comments

Comments
 (0)