From rowan.collins at gmail.com Sat Jun 19 20:50:32 2010 From: rowan.collins at gmail.com (Rowan Collins) Date: Sun, 20 Jun 2010 01:50:32 +0100 Subject: [iCalendar-devel] Windows line endings not handled correctly Message-ID: <4C1D65D8.2020207@gmail.com> Hi, I've been using this library to re-encode some information from a 3rd-party API, and Google Calendar was failing to parse the results. I believe I've tracked down the problem to the handling of line endings when setting properties. Given the string "a\r\nb" as input, the output will be "a\r\\nb" - the CR is output literally, but the LF is escaped as '\n'. An interpreter might consider the CR to be a newline, and the '\n' (since it is not indented) to be the next property in the file. The correct action in this example would be to escape the entire CRLF sequence as a single '\n', or more generally to normalise all line endings before encoding. It appears that VPIM has the same problem, but RiCal appears to handle this situation correctly. Example: require 'icalendar' Icalendar::Calendar.new.tap{ |cal| cal.event do description "a\r\nb" end }.to_ical # => "BEGIN:VCALENDAR\r\nCALSCALE:GREGORIAN\r\nPRODID:iCalendar-Ruby\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nDESCRIPTION:a\r\\nb\r\nDTSTAMP:20100620T011601\r\nSEQUENCE:0\r\nUID:2010-06-20T01:16:01+01:00_969670122 at Norman\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n" # should be # => "BEGIN:VCALENDAR\r\nCALSCALE:GREGORIAN\r\nPRODID:iCalendar-Ruby\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nDESCRIPTION:a\\nb\r\nDTSTAMP:20100620T011601\r\nSEQUENCE:0\r\nUID:2010-06-20T01:16:01+01:00_969670122 at Norman\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n" Regards, Rowan Collins From rowan.collins at gmail.com Sun Jun 20 09:55:10 2010 From: rowan.collins at gmail.com (Rowan Collins) Date: Sun, 20 Jun 2010 14:55:10 +0100 Subject: [iCalendar-devel] Windows line endings not handled correctly In-Reply-To: <4C1D65D8.2020207@gmail.com> References: <4C1D65D8.2020207@gmail.com> Message-ID: <4C1E1DBE.6040000@gmail.com> Hi, Sorry to follow-up to my own post, but now it's not so late at night, here's a quick patch to fix the bug mentioned. Regards, Rowan Collins On 20/06/10 01:50, Rowan Collins wrote: > Hi, > > I've been using this library to re-encode some information from a > 3rd-party API, and Google Calendar was failing to parse the results. I > believe I've tracked down the problem to the handling of line endings > when setting properties. > > Given the string "a\r\nb" as input, the output will be "a\r\\nb" - the > CR is output literally, but the LF is escaped as '\n'. An interpreter > might consider the CR to be a newline, and the '\n' (since it is not > indented) to be the next property in the file. > > The correct action in this example would be to escape the entire CRLF > sequence as a single '\n', or more generally to normalise all line > endings before encoding. > > It appears that VPIM has the same problem, but RiCal appears to handle > this situation correctly. > > Example: > > require 'icalendar' > Icalendar::Calendar.new.tap{ |cal| cal.event do description "a\r\nb" > end }.to_ical > # => > "BEGIN:VCALENDAR\r\nCALSCALE:GREGORIAN\r\nPRODID:iCalendar-Ruby\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nDESCRIPTION:a\r\\nb\r\nDTSTAMP:20100620T011601\r\nSEQUENCE:0\r\nUID:2010-06-20T01:16:01+01:00_969670122 at Norman\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n" > > > # should be > # => > "BEGIN:VCALENDAR\r\nCALSCALE:GREGORIAN\r\nPRODID:iCalendar-Ruby\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nDESCRIPTION:a\\nb\r\nDTSTAMP:20100620T011601\r\nSEQUENCE:0\r\nUID:2010-06-20T01:16:01+01:00_969670122 at Norman\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n" > > > Regards, > Rowan Collins -------------- next part -------------- A non-text attachment was scrubbed... Name: icalendar-line-endings.patch Type: text/x-patch Size: 589 bytes Desc: not available URL: From sean at dague.net Mon Jun 21 09:32:42 2010 From: sean at dague.net (Sean Dague) Date: Mon, 21 Jun 2010 09:32:42 -0400 Subject: [iCalendar-devel] Windows line endings not handled correctly In-Reply-To: <4C1E1DBE.6040000@gmail.com> References: <4C1D65D8.2020207@gmail.com> <4C1E1DBE.6040000@gmail.com> Message-ID: <4C1F69FA.8030909@dague.net> On 06/20/2010 09:55 AM, Rowan Collins wrote: > Hi, > > Sorry to follow-up to my own post, but now it's not so late at night, > here's a quick patch to fix the bug mentioned. > > Regards, > Rowan Collins Thank you for the bug and the fix. Patch applied and version 1.1.5 is now released with your changes included. -Sean -- __________________________________________________________________ Sean Dague Mid-Hudson Valley sean at dague dot net Linux Users Group http://dague.net http://mhvlug.org There is no silver bullet. Plus, werewolves make better neighbors than zombies, and they tend to keep the vampire population down. __________________________________________________________________ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 190 bytes Desc: OpenPGP digital signature URL: