diff --git a/date_api/date_api_ical.inc b/date_api/date_api_ical.inc index 2ca484e..ef3a19f 100644 --- a/date_api/date_api_ical.inc +++ b/date_api/date_api_ical.inc @@ -722,6 +722,9 @@ function date_api_ical_build_rrule($form_values) { if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY']) && $BYMONTHDAY = implode(",", $form_values['BYMONTHDAY'])) { $RRULE .= ';BYMONTHDAY=' . $BYMONTHDAY; } + + // We can only set UNTIL OR COUNT. We cannot set both per RFC-2445. + // The UNTIL date is supposed to always be expressed in UTC. // The input date values may already have been converted to a date object on a // previous pass, so check for that. @@ -741,10 +744,10 @@ function date_api_ical_build_rrule($form_values) { $until = $form_values['UNTIL']['datetime']; } $RRULE .= ';UNTIL=' . date_format($until, DATE_FORMAT_ICAL) . 'Z'; - } + } else if (array_key_exists('COUNT', $form_values) && is_int($form_values['COUNT'])) { // Our form doesn't allow a value for COUNT, but it may be needed by // modules using the API, so add it to the rule. - if (array_key_exists('COUNT', $form_values)) { + // COUNT is not allowed to be empty per RFC-2445. $RRULE .= ';COUNT=' . $form_values['COUNT']; }