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

Line folding breaks surrogate pairs #221

Closed
HeikoTheissen opened this issue Dec 23, 2020 · 1 comment
Closed

Line folding breaks surrogate pairs #221

HeikoTheissen opened this issue Dec 23, 2020 · 1 comment
Labels

Comments

@HeikoTheissen
Copy link
Contributor

HeikoTheissen commented Dec 23, 2020

return line.match(/(.{1,74})/g).join('\r\n ');

Folding an iCalendar line after every 74 characters does not work if the 74th and 75th character form a surrogate pair. iCalendar clients are unable to reconstitute the pair if it is split across two lines.

For example,

'use strict';

const ical = require('ical-generator');
const moment = require('moment');
const cal = ical({domain: 'localhost'});

// overwrite domain
cal.domain('example.com');

const event = cal.createEvent({
    start: moment().add(1, 'hour'),
    end: moment().add(2, 'hours'),
    summary: '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF:📞'
});

console.log(cal.toString());

produces output where the telephone symbol is split and rendered by Google Calendar as ...ABCDEF:��. In such cases, the split must happen before the 74th character.

Moreover, even in the absence of surrogate pairs, a line with 74 Unicode characters (which are not all ASCII) can have more than 74 octets and so exceed the limit suggested in the RFC.

@sebbo2002
Copy link
Owner

🎉 Released in 1.15.4, thank you.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants