Skip to content
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

FormatException in an invitation with start and end date sent via GMX #236

Closed
ThePeat94 opened this issue Feb 7, 2017 · 4 comments
Closed

Comments

@ThePeat94
Copy link

Hello,

I was trying to parse a invitation for a meeting, having a start and enddate (not allday). Following error occured:

Error in ConvertMailMessagesToMeetings! System.FormatException: String was not recognized as a valid DateTime.
   at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles, TimeSpan& offset)
   at System.DateTimeOffset.Parse(String input)
   at Ical.Net.Serialization.iCalendar.Serializers.DataTypes.UtcOffsetSerializer.GetOffset(String rawOffset) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\Serializers\DataTypes\UTCOffsetSerializer.cs:line 42
   at Ical.Net.Serialization.iCalendar.Serializers.DataTypes.UtcOffsetSerializer.Deserialize(TextReader tr) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\Serializers\DataTypes\UTCOffsetSerializer.cs:line 31
   at Ical.Net.Serialization.iCalendar.Serializers.DataMapSerializer.Deserialize(TextReader tr) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\Serializers\DataMapSerializer.cs:line 56
   at Ical.Net.Serialization.iCalendar.iCalParser.property(ISerializationContext ctx, ICalendarPropertyListContainer c) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\iCalParser.cs:line 292
   at Ical.Net.Serialization.iCalendar.iCalParser.component(ISerializationContext ctx, ISerializerFactory sf, ICalendarComponentFactory cf, ICalendarObject o) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\iCalParser.cs:line 415
   at Ical.Net.Serialization.iCalendar.iCalParser.component(ISerializationContext ctx, ISerializerFactory sf, ICalendarComponentFactory cf, ICalendarObject o) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\iCalParser.cs:line 420
   at Ical.Net.Serialization.iCalendar.iCalParser.icalbody(ISerializationContext ctx, ICalendar cal) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\iCalParser.cs:line 207
   at Ical.Net.Serialization.iCalendar.iCalParser.icalendar(ISerializationContext ctx) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\iCalParser.cs:line 144
   at Ical.Net.Serialization.iCalendar.Serializers.CalendarSerializer.Deserialize(TextReader tr) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\Serializers\CalendarSerializer.cs:line 66
   at Ical.Net.Serialization.iCalendar.Serializers.SerializerBase.Deserialize(Stream stream, Encoding encoding) in C:\git\ical.net\v2\ical.net\Serialization\iCalendar\Serializers\SerializerBase.cs:line 39
   at Ical.Net.Calendar.LoadFromFile(String filepath, Encoding encoding, ISerializer serializer) in C:\git\ical.net\v2\ical.net\Calendar.cs:line 65
   at Ical.Net.Calendar.LoadFromFile(String filepath) in C:\git\ical.net\v2\ical.net\Calendar.cs:line 30
   at MeetingTestTool.Classes.MeetingParser.ConvertMailMessagesToMeetings(List`1 mailMessages) in D:\SVN\Azubi\HR\MeetingTestTool\MeetingTestTool\Classes\MeetingParser.cs:line 31

Test Method (contains content of the invitation):

public static void ParseMeetingWithDuration()
{
	const string ical =
@"BEGIN:VCALENDAR
PRODID:-//1&1 Mail & Media GmbH/GMX Kalender Server 3.10.0//NONSGML//DE
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTAMP:20170207T113248Z
DTEND;TZID=Europe/Brussels:20170207T093000
DTSTART;TZID=Europe/Brussels:20170207T083000
SUMMARY:neue testbesprechung
ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE;[email protected]:MAILTO:[email protected]
ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE;[email protected]:MAILTO:[email protected]
ORGANIZER;CN=Max Mustermann:MAILTO:[email protected]
DESCRIPTION:blubb
LOCATION:am neuen testort
UID:d950915c-d667-4e57-8b69-221b7bb8548d.kalender.gmx.net
SEQUENCE:0
END:VEVENT
BEGIN:VTIMEZONE
TZID:Europe/Brussels
TZURL:http://tzurl.org/zoneinfo/Europe/Brussels
X-LIC-LOCATION:Europe/Brussels
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19810329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19961027T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+001730
TZOFFSETTO:+001730
TZNAME:BMT
DTSTART:18800101T000000
RDATE:18800101T000000
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+001730
TZOFFSETTO:+0000
TZNAME:WET
DTSTART:18920501T120000
RDATE:18920501T120000
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19141108T000000
RDATE:19141108T000000
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19160501T230000
RDATE:19160501T230000
RDATE:19170416T020000
RDATE:19180415T020000
RDATE:19400520T030000
RDATE:19430329T020000
RDATE:19440403T020000
RDATE:19450402T020000
RDATE:19460519T020000
RDATE:19770403T020000
RDATE:19780402T020000
RDATE:19790401T020000
RDATE:19800406T020000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19161001T010000
RDATE:19161001T010000
RDATE:19170917T030000
RDATE:19180916T030000
RDATE:19421102T030000
RDATE:19431004T030000
RDATE:19440917T030000
RDATE:19450916T020000
RDATE:19461007T030000
RDATE:19770925T030000
RDATE:19781001T030000
RDATE:19790930T030000
RDATE:19800928T030000
RDATE:19810927T030000
RDATE:19820926T030000
RDATE:19830925T030000
RDATE:19840930T030000
RDATE:19850929T030000
RDATE:19860928T030000
RDATE:19870927T030000
RDATE:19880925T030000
RDATE:19890924T030000
RDATE:19900930T030000
RDATE:19910929T030000
RDATE:19920927T030000
RDATE:19930926T030000
RDATE:19940925T030000
RDATE:19950924T030000
END:STANDARD
BEGIN:STANDARD
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
TZNAME:WET
DTSTART:19181111T120000
RDATE:19181111T120000
RDATE:19191005T000000
RDATE:19201024T000000
RDATE:19211026T000000
RDATE:19221008T000000
RDATE:19231007T000000
RDATE:19241005T000000
RDATE:19251004T000000
RDATE:19261003T000000
RDATE:19271002T000000
RDATE:19281007T030000
RDATE:19291006T030000
RDATE:19301005T030000
RDATE:19311004T030000
RDATE:19321002T030000
RDATE:19331008T030000
RDATE:19341007T030000
RDATE:19351006T030000
RDATE:19361004T030000
RDATE:19371003T030000
RDATE:19381002T030000
RDATE:19391119T030000
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
TZNAME:WEST
DTSTART:19190301T230000
RDATE:19190301T230000
RDATE:19200214T230000
RDATE:19210314T230000
RDATE:19220325T230000
RDATE:19230421T230000
RDATE:19240329T230000
RDATE:19250404T230000
RDATE:19260417T230000
RDATE:19270409T230000
RDATE:19280414T230000
RDATE:19290421T020000
RDATE:19300413T020000
RDATE:19310419T020000
RDATE:19320403T020000
RDATE:19330326T020000
RDATE:19340408T020000
RDATE:19350331T020000
RDATE:19360419T020000
RDATE:19370404T020000
RDATE:19380327T020000
RDATE:19390416T020000
RDATE:19400225T020000
END:DAYLIGHT
BEGIN:DAYLIGHT
TZOFFSETFROM:+0200
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19440903T000000
RDATE:19440903T000000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0100
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19770101T000000
RDATE:19770101T000000
END:STANDARD
END:VTIMEZONE
END:VCALENDAR";
	try
	{
		// With the given string it throws a FormatException
		IICalendarCollection meetingInvitation = Calendar.LoadFromStream(new StringReader(ical));

		/* Further processing like reading the organizer, attendees, start, end, location...
		 * ...
		 * ...
		 * ...
		 */
	}
	catch (Exception ex)
	{
		// Log Error
	}
}

The parsing process is successful, when I delete all standard sections. It is also parsing successfully using allday meetings. This invitation was sent via GMX. Sent invitations from Outlook or Thunderbird are working fine.

Greetings

@ThePeat94 ThePeat94 changed the title FormatException in an invitation with start and end date FormatException in an invitation with start and end date sent via GMX Feb 7, 2017
@rianjs
Copy link
Collaborator

rianjs commented Feb 7, 2017

Yup, looks like an offset parsing bug. Not a huge surprise, the RFC spec for an offset differs from .NET's offset parsing semantics.

I have a fix, and I should have time to publish it tomorrow.

@aluxnimm
Copy link

aluxnimm commented Feb 7, 2017

this is a duplicate of #102

@ThePeat94
Copy link
Author

Thank you rianjs, for taking time fixing this, I really appreciate it.

rianjs pushed a commit that referenced this issue Feb 8, 2017
@rianjs
Copy link
Collaborator

rianjs commented Feb 8, 2017

Thanks, @aluxnimm

Fix published in nuget version 2.2.32:
https://www.nuget.org/packages/Ical.Net

@rianjs rianjs closed this as completed Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants