Commit 348075b8 authored by Sebastian's avatar Sebastian
Browse files

Merge branch 'takkaria-fix-crlf' into develop

parents f4518585 ca1fabcf
......@@ -28,13 +28,9 @@ module.exports.formatDate = function formatDate(d, dateonly, floating) {
};
module.exports.escape = function escape(str) {
return str.replace(/[\\;,\n"]/g, function(match) {
if(match === '\n') {
return '\\n';
}
return str.replace(/[\\;,"]/g, function(match) {
return '\\' + match;
});
}).replace(/(?:\r\n|\r|\n)/g, '\\n');
};
module.exports.duration = function duration(seconds) {
......
......@@ -780,6 +780,18 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
event.summary('Example Event II');
assert.ok(str !== cal.toString());
});
it('should escape CR/CRLF line breaks', function() {
var cal = ical(),
event = cal.createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example with a\rlinebreak'
}),
str = cal.toString();
assert.equal(str.indexOf('\rlinebreak'), -1);
});
});
describe('location()', function() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment