New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTSTAMP compatibility: accept erroneous TZID parameters #303

Open
rfc2822 opened this Issue Jan 4, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@rfc2822
Copy link
Contributor

rfc2822 commented Jan 4, 2019

Hello,

Many iCalendars out there (especially Webcal feeds generated by PHP scripts etc.) contain DTSTAMP values with TZID parameter like that:

DTSTAMP;TZID=Europe/Prague:20190104T155229 

According to the iCalendar RFC, this is invalid and it causes ical4j to fail with:

Caused by: net.fortuna.ical4j.data.ParserException: Error at line xx:Cannot set timezone for UTC properties
    at net.fortuna.ical4j.data.CalendarParserImpl.parse(CalendarParserImpl.java:158)
    at net.fortuna.ical4j.data.CalendarBuilder.build(CalendarBuilder.java:198)
    at net.fortuna.ical4j.data.CalendarBuilder.build(CalendarBuilder.java:178) 
    at at.bitfire.ical4android.Event$Companion.fromReader(Event.kt:78)
    at ...
Caused by: java.lang.UnsupportedOperationException: Cannot set timezone for UTC properties
    at net.fortuna.ical4j.model.property.UtcProperty.setTimeZone(UtcProperty.java:95)
    at net.fortuna.ical4j.data.CalendarBuilder.updateTimeZone(CalendarBuilder.java:353)
    at net.fortuna.ical4j.data.CalendarBuilder.access$300(CalendarBuilder.java:68)
    at net.fortuna.ical4j.data.CalendarBuilder$ContentHandlerImpl.parameter(CalendarBuilder.java:278)
    at net.fortuna.ical4j.data.CalendarParserImpl$ParameterParser.parse(CalendarParserImpl.java:367)

While this is technically correct, it often causes compability problems.

Would it be possible to accept time values with time zone when ical4j.parsing.relaxed is true?

@benfortuna

This comment has been minimized.

Copy link
Member

benfortuna commented Jan 4, 2019

The thing about DTSTAMP is that the RFC specifically states it should be UTC time, presumably because it avoids ambiguity when dealing with historical timezone definitions.

As such ical4j implements as a UTC property that can't have a timezone even in relaxed mode.

What we could explore is transforming the input calendar to convert the timezone-based value to a UTC value when parsing.

@rfc2822

This comment has been minimized.

Copy link
Contributor

rfc2822 commented Jan 4, 2019

The thing about DTSTAMP is that the RFC specifically states it should be UTC time, presumably because it avoids ambiguity when dealing with historical timezone definitions.

I think it might also be helpful for servers which use the DTSTAMP to determine when events have been updated. To convert the DTSTAMP into a last-modified timestamp reliably, there should be no time zones to consider.

But whatever the reasons behind this are: Although I don't like it, there are many iCalendars out there which contain DTSTAMP with TZID, and parsing completely fails for all those events.

As such ical4j implements as a UTC property that can't have a timezone even in relaxed mode.

What about:

  1. Allowing time zones not only for DTSTAMP, but for all UTC properties in relaxed mode?
  2. At least ignoring invalid UTC properties in relaxed mode? Actually I don't need the DTSTAMP value, but the parser throws an exception, so that the whole iCalendar can't be used, which really causes problems…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment