Skip to content

Commit

Permalink
icalrecur: Ignore time-related BY* if DTSTART is date-only.
Browse files Browse the repository at this point in the history
  • Loading branch information
minichma committed Oct 19, 2024
1 parent 795de36 commit a149d6d
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/libical/icalrecur.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,26 +756,27 @@ static struct recur_map
const char *str;
size_t offset;
int limit;
int isTime;
} recur_map[] = {
{ ";BYSECOND=", offsetof(struct icalrecurrencetype, by_second),
ICAL_BY_SECOND_SIZE - 1 },
ICAL_BY_SECOND_SIZE - 1, 1 },
{ ";BYMINUTE=", offsetof(struct icalrecurrencetype, by_minute),
ICAL_BY_MINUTE_SIZE - 1 },
ICAL_BY_MINUTE_SIZE - 1, 1 },
{ ";BYHOUR=", offsetof(struct icalrecurrencetype, by_hour),
ICAL_BY_HOUR_SIZE - 1 },
ICAL_BY_HOUR_SIZE - 1, 1 },
{ ";BYDAY=", offsetof(struct icalrecurrencetype, by_day),
ICAL_BY_DAY_SIZE - 1 },
ICAL_BY_DAY_SIZE - 1, 0 },
{ ";BYMONTHDAY=", offsetof(struct icalrecurrencetype, by_month_day),
ICAL_BY_MONTHDAY_SIZE - 1 },
ICAL_BY_MONTHDAY_SIZE - 1, 0 },
{ ";BYYEARDAY=", offsetof(struct icalrecurrencetype, by_year_day),
ICAL_BY_YEARDAY_SIZE - 1 },
ICAL_BY_YEARDAY_SIZE - 1, 0 },
{ ";BYWEEKNO=", offsetof(struct icalrecurrencetype, by_week_no),
ICAL_BY_WEEKNO_SIZE - 1 },
ICAL_BY_WEEKNO_SIZE - 1, 0 },
{ ";BYMONTH=", offsetof(struct icalrecurrencetype, by_month),
ICAL_BY_MONTH_SIZE - 1 },
ICAL_BY_MONTH_SIZE - 1, 0 },
{ ";BYSETPOS=", offsetof(struct icalrecurrencetype, by_set_pos),
ICAL_BY_SETPOS_SIZE - 1 },
{ 0, 0, 0 }
ICAL_BY_SETPOS_SIZE - 1, 0 },
{ 0, 0, 0, 0 }
};

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

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

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

0 comments on commit a149d6d

Please sign in to comment.