mangstadt / biweekly

biweekly is an iCalendar library written in Java.
BSD 2-Clause "Simplified" License
323 stars 44 forks source link

ClassCastException while parsing an invite with incorrect DTStart values in the VTimezone component #77

Closed krshmbb closed 6 years ago

krshmbb commented 7 years ago

We've noticed a few cases of clients sending us malformed VTimeZone DTStart values (not matching the local date-time format). As a result, ICalReader.readNext() throws a ClassCastException (java.lang.ClassCastException: biweekly.util.com.google.ical.values.DateValueImpl cannot be cast to biweekly.util.com.google.ical.values.DateTimeValue).

I've narrowed this down to Google2445Utils.convert(DateTimeComponents) which returns a DateValueImpl object when the component has no time. This eventually results in a ClassCastException at ICalTimeZone#getObservanceBoundary().

java.lang.ClassCastException: biweekly.util.com.google.ical.values.DateValueImpl cannot be cast to biweekly.util.com.google.ical.values.DateTimeValue at biweekly.io.ICalTimeZone.b(ICalTimeZone.java:364) at biweekly.io.ICalTimeZone.a(ICalTimeZone.java:273) at biweekly.io.ICalTimeZone.b(ICalTimeZone.java:282) at biweekly.io.ICalTimeZone.b(ICalTimeZone.java:208) at biweekly.io.ICalTimeZone.(ICalTimeZone.java:94) at biweekly.io.StreamReader.a(StreamReader.java:182) at biweekly.io.StreamReader.b(StreamReader.java:156)

mangstadt commented 7 years ago

Can you send me the iCal file that causes this error?

In the Gitter channel, you mentioned that you have a unit test and a possible solution. Can you send those as well?

krshmbb commented 7 years ago

Raised a PR with a unit test. I work for VMware and we have to go through a process to push up any code contributions. I am waiting on that for the rest.

mangstadt commented 7 years ago

Thanks. I refactored your unit test and moved it to a place that is closer to where the issue is located. See: dff04782e0fe5ff2efca51fe55368271e5e177d3

Note: Here is the PR that @krshmbb is referring to: https://github.com/mangstadt/biweekly/pull/78