Bugs: Browse | Submit New | Admin

[#28311] Windows line endings in values not handled correctly

Date:
2010-06-20 00:39
Priority:
3
Submitted By:
Rowan Collins (imsop)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Windows line endings in values not handled correctly

Detailed description
When creating, for example, an iCal event based on external input, Windows line endings ("\r\n") will cause
some apparently invalid output (in particular, I believe it will break imports into Google Calendar).

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.

Example:

require 'vpim/icalendar'
(Vpim::Icalendar.create2.add_event do |e| e.description "a\r\nb" end).encode
# => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Ensemble Independent//vPim
0.695//EN\nCALSCALE:Gregorian\nBEGIN:VEVENT\nDTSTART:20100620T010854\nDESCRIPTION:a\r\\nb\nEND:VEVENT\nEND:VCALENDAR\n&q
uot;

Should give:
# => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Ensemble Independent//vPim
0.695//EN\nCALSCALE:Gregorian\nBEGIN:VEVENT\nDTSTART:20100620T010854\nDESCRIPTION:a\\nb\nEND:VEVENT\nEND:VCALENDAR\n&quo
t;

Add A Comment: Notepad

Please login


Followup

Message
Date: 2010-06-20 00:42
Sender: Rowan Collins

Incidentally, the 'icalendar' lib
(http://rubyforge.org/projects/icalendar/) has the same
problem, but RiCal seems to handle this case correctly.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item