Search code examples
c++chartimezoneicalendarmalformed

iCal - can a TimeZone TZID parameter contain a ":" char?


In a c++ project, I'm writing a parser to read from and write to .ics files. To do that, I test my parser against several files with a maximum of possible cases, from several sources (gmail, yahoo, ...). Recently I found in a test file a situation that leaves me a little confused, and for which I could not find a satisfactory answer.

One of my test file failed to be imported by my parser. The VEVENT that cause the issue contains the following start date:

DTSTART;TZID=GMT+04:00:20120103T120000

This event match with a VTIMEZONE, that declares his TZID parameter as follow:

TZID:GMT+04:00

AFAIK the ":" char should be instead used as separator, and I suspect that the VTIMEZONE itself is malformed in the sample described above, but I didn't find any document that explicitly specifies that this situation can never happen. I also noticed that several apps like Thunderbird also fail to import this file, apparently for the same reason.

So my question is: can a TZID parameter in a VTIMEZONE contain a ":" char?

Also, I don't know if I should use the TZID content as a key to extract the ISO date from the DTSTART parameter, or if I do simply reject a such event, tagging it as corrupted, and showing an error message after the importation?


Solution

  • The authority on this is RFC5545 and the relevant subsections: RFC5545 3.2.19. Time Zone Identifier

    tzidparam = "TZID" "=" [tzidprefix] paramtext

    which is complemented by RFC5545 3.1. Content Lines

    param = param-name "=" param-value *("," param-value)
    param-value = paramtext / quoted-string
    paramtext = *SAFE-CHAR
    [..]
    SAFE-CHAR = WSP / %x21 / %x23-2B / %x2D-39 / %x3C-7E
    / NON-US-ASCII
    ; Any character except CONTROL, DQUOTE, ";", ":", ","

    From which we can conclude that a Time Zone ID parameter cannot contain a ":" char.