in_daylight = 1;
params = &timezone->daylight_params;
} else if (! strcasecmp ("TZID", node->name)) {
- timezone->tzid = strdup (node->value);
+ /* See comment below in format_datetime() about removing any enclosing quotes from a
+ timezone identifier. */
+ char *buf = mh_xmalloc(strlen(node->value) + 1);
+ unquote_string(node->value, buf);
+ timezone->tzid = buf;
}
} else {
if (! strcasecmp ("BEGIN", node->name) &&
/* Extract the timezone, if specified (RFC 5545 Sec. 3.3.5 Form #3). */
for (p = node->params; p && p->param_name; p = p->next) {
if (! strcasecmp (p->param_name, "TZID") && p->values) {
- dt_timezone = p->values->value;
+ /* Remove any enclosing quotes from the timezone identifier. I don't believe that it's
+ legal for it to be quoted, according to RFC 5545 ยง 3.2.19:
+ tzidparam = "TZID" "=" [tzidprefix] paramtext
+ tzidprefix = "/"
+ where paramtext includes SAFE-CHAR, which specifically excludes DQUOTE. But we'll
+ be generous and strip quotes. */
+ char *buf = mh_xmalloc(strlen(p->values->value) + 1);
+ unquote_string(p->values->value, buf);
+ dt_timezone = buf;
break;
}
}
if (tz->tzid && ! strcasecmp (dt_timezone, tz->tzid)) { break; }
}
- if (! tz) {
+ if (tz) {
+ free(dt_timezone);
+ } else {
advise (NULL, "did not find VTIMEZONE section for %s", dt_timezone);
+ free(dt_timezone);
return NULL;
}
rm -f "$MH_TEST_DIR/test1.ics"
+# Check TZID name wrapped with quotes, this used to cause a segfault.
+cat >"$expected" <<'EOF'
+Method: REQUEST
+Summary: Quoted timezone ID
+At: Wed, 01 Jan 2014 00:00
+To: Wed, 01 Jan 2014 01:00
+EOF
+
+cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
+BEGIN:VCALENDAR
+PRODID:Zimbra-Calendar-Provider
+VERSION:2.0
+METHOD:REQUEST
+SUMMARY:Quoted timezone ID
+BEGIN:VTIMEZONE
+TZID:Etc/GMT
+BEGIN:STANDARD
+DTSTART:19710101T000000
+TZOFFSETTO:-0000
+TZOFFSETFROM:-0000
+TZNAME:GMT
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+DTSTART:20140101T000000
+DTEND;TZID="Etc/GMT":20140101T010000
+SEQUENCE:0
+END:VEVENT
+END:VCALENDAR
+EOF
+
+TZ=UTC mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
+check "$expected" "$MH_TEST_DIR/test1.txt"
+rm -f "$MH_TEST_DIR/test1.ics"
+
+
exit $failed