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

stringify: do not use unescapedIndexOf in property parameters #658

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/ical/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Portions Copyright (C) Philipp Kewisch */

import design from "./design.js";
import { foldline, unescapedIndexOf } from "./helpers.js";
import { foldline } from "./helpers.js";

const LINE_ENDING = '\r\n';
const DEFAULT_VALUE_TYPE = 'unknown';
Expand Down Expand Up @@ -131,7 +131,6 @@ stringify.property = function(property, designSet, noFold) {
value = stringify.paramPropertyValue(value);
}


line += ';' + paramName.toUpperCase() + '=' + value;
}

Expand Down Expand Up @@ -216,9 +215,9 @@ stringify.property = function(property, designSet, noFold) {
*/
stringify.paramPropertyValue = function(value, force) {
if (!force &&
(unescapedIndexOf(value, ',') === -1) &&
(unescapedIndexOf(value, ':') === -1) &&
(unescapedIndexOf(value, ';') === -1)) {
(value.indexOf(',') === -1) &&
(value.indexOf(':') === -1) &&
(value.indexOf(';') === -1)) {

return value;
}
Expand Down
7 changes: 7 additions & 0 deletions test/stringify_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ suite('ICAL.stringify', function() {
delete ICAL.design.defaultSet.param.type;
});

test('stringify property value containing "escaped" semicolons, commas, colons', function() {
let subject = new ICAL.Property('attendee');
subject.setParameter('cn', 'X\\:');
subject.setValue('mailto:id');
assert.equal(subject.toICALString(), 'ATTENDEE;CN="X\\:":mailto:id');
});

test('rfc6868 roundtrip', function() {
let subject = new ICAL.Property('attendee');
let input = "caret ^ dquote \" newline \n end";
Expand Down