summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Murchison <murch@fastmail.com>2020-05-01 09:24:23 -0400
committerKen Murchison <murch@fastmail.com>2020-05-01 09:24:23 -0400
commite3a2208f53b4edf9abc910b5edd5c36a5be2ede2 (patch)
tree394eb8de3f58524eb701e188940278791c9ea3d3
parente1248276636b970cff9ec655d5b768e01c08d85d (diff)
downloadlibical-git-issue_428.tar.gz
issue #428: ignore BYYEARDAY when used with FREQ=MONTHLYissue_428
-rw-r--r--src/libical/icalrecur.c10
-rw-r--r--src/test/icalrecur_test.c5
-rw-r--r--src/test/icalrecur_test.out5
3 files changed, 17 insertions, 3 deletions
diff --git a/src/libical/icalrecur.c b/src/libical/icalrecur.c
index 2a487adb..bd3a9c96 100644
--- a/src/libical/icalrecur.c
+++ b/src/libical/icalrecur.c
@@ -994,7 +994,8 @@ enum expand_table
UNKNOWN = 0,
CONTRACT = 1,
EXPAND = 2,
- ILLEGAL = 3
+ ILLEGAL = 3,
+ IGNORE = 4
};
/**
@@ -1021,7 +1022,7 @@ static const struct expand_split_map_struct expand_map[] = {
{ICAL_HOURLY_RECURRENCE, { 2, 2, 1, 1, 1, 1, 3, 1, 1 }},
{ICAL_DAILY_RECURRENCE, { 2, 2, 2, 1, 1, 3, 3, 1, 1 }},
{ICAL_WEEKLY_RECURRENCE, { 2, 2, 2, 2, 3, 3, 3, 1, 1 }},
- {ICAL_MONTHLY_RECURRENCE, { 2, 2, 2, 2, 2, 3, 3, 1, 1 }},
+ {ICAL_MONTHLY_RECURRENCE, { 2, 2, 2, 2, 2, 4, 3, 1, 1 }},
{ICAL_YEARLY_RECURRENCE, { 2, 2, 2, 2, 2, 2, 2, 2, 1 }},
{ICAL_NO_RECURRENCE, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }} //krazy:exclude=style
};
@@ -2000,11 +2001,14 @@ icalrecur_iterator *icalrecur_iterator_new(struct icalrecurrencetype rule,
for (byrule = BY_SECOND; byrule <= BY_SET_POS; byrule++) {
if (expand_map[freq].map[byrule] == ILLEGAL &&
- impl->by_ptrs[byrule][0] != ICAL_RECURRENCE_ARRAY_MAX) {
+ has_by_data(impl, byrule)) {
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
free(impl);
return 0;
}
+ else if (expand_map[freq].map[byrule] == IGNORE) {
+ impl->orig_data[byrule] = 0;
+ }
}
if (initialize_rscale(impl) == 0) {
diff --git a/src/test/icalrecur_test.c b/src/test/icalrecur_test.c
index ec5dbafb..92c4cfe7 100644
--- a/src/test/icalrecur_test.c
+++ b/src/test/icalrecur_test.c
@@ -390,6 +390,11 @@ const struct recur rfc5545[] = {
"FREQ=WEEKLY;BYDAY=WE,FR;INTERVAL=2;COUNT=4",
NULL},
+ /* github issue428 */
+ {"20200101T100000",
+ "FREQ=MONTHLY;BYYEARDAY=-1;BYMONTHDAY=-1;COUNT=13",
+ NULL},
+
{NULL, NULL, NULL}
};
diff --git a/src/test/icalrecur_test.out b/src/test/icalrecur_test.out
index e4f55179..210f9b0f 100644
--- a/src/test/icalrecur_test.out
+++ b/src/test/icalrecur_test.out
@@ -339,3 +339,8 @@ RRULE:FREQ=WEEKLY;BYDAY=WE,FR;INTERVAL=2;COUNT=4
DTSTART:20190101T100000
INSTANCES:20190102T100000,20190104T100000,20190116T100000,20190118T100000
PREV-INSTANCES:20190116T100000,20190104T100000,20190102T100000
+
+RRULE:FREQ=MONTHLY;BYYEARDAY=-1;BYMONTHDAY=-1;COUNT=13
+DTSTART:20200101T100000
+INSTANCES:20200131T100000,20200229T100000,20200331T100000,20200430T100000,20200531T100000,20200630T100000,20200731T100000,20200831T100000,20200930T100000,20201031T100000,20201130T100000,20201231T100000,20210131T100000
+PREV-INSTANCES:20201231T100000,20201130T100000,20201031T100000,20200930T100000,20200831T100000,20200731T100000,20200630T100000,20200531T100000,20200430T100000,20200331T100000,20200229T100000,20200131T100000