ical.js icon indicating copy to clipboard operation
ical.js copied to clipboard

Quoted TZIDs are incorrectly parsed

Open castaway opened this issue 5 years ago • 4 comments

While the spec says that certain values MUST be quoted, and that other params containing commas, semicolons and colons MUST be quoted, it seems to be a bit silent on whether its allowed to quote other strings or not.

I happen to be using an example that contains DTSTART;TZID="Eastern" (where Eastern is defined in the VTIMEZONEs), the tzid part gets parsed as "tzid;&quot", and we lose the "Eastern" completely.

https://icalevents.com/2108-tzids-with-quotes-around-them/ <- not mine but it seems someone else came across the same thing

See also: https://www.rfc-editor.org/errata/eid5505

castaway avatar Oct 08 '20 18:10 castaway

I think it should be allowed to quote other strings, or at least ical.js should understand that and unquote.

Related but just FYI, there is also rfc6868 for alternative ways to quote.

kewisch avatar Oct 12 '20 06:10 kewisch

Agreed, maybe drop the special "might be a quoted multi-value" boolean flag, and check all values for surrounding quotes?

castaway avatar Oct 12 '20 08:10 castaway

Oh interesting, I didn't check the code. If there is already a flag for it then there might have been a reason. I'll have to double check the rfc, and/or get some advice on the calsify list.

kewisch avatar Oct 12 '20 08:10 kewisch

As far as I can see its currently only special casing the "items separated by commas" part of the spec.. ignoring anything that "might contain a comma, semi-colon or colon" (tho I may have missed something)

castaway avatar Oct 12 '20 08:10 castaway

I believe this was due to various issues in parsing quoted parameters, not specific to TZID or timezones. There were a few issues fixed recently, and one more filed but not fixed. For the purpose of this issue I think we are good. I've tried the following:

    let x = ICAL.parse('BEGIN:VCALENDAR\nBEGIN:VEVENT\nDTSTART;TZID="Eastern":20210101T010203\nEND:VEVENT\nEND:VCALENDAR');
    let comp = new ICAL.Component(x);
    console.log(JSON.stringify(comp.toJSON()));

And get this:

["vcalendar",[],[["vevent",[["dtstart",{"tzid":"Eastern"},"date-time","2021-01-01T01:02:03"]],[]]]]

If I missed something please reopen or file a new issue.

kewisch avatar May 04 '24 06:05 kewisch