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

Parser splits vCard ADR parameter "LABEL" at comma despite quoting (when it appears after multi-value parameter "TYPE") #386

Closed
caugner opened this issue Apr 5, 2019 · 1 comment · Fixed by #387

Comments

@caugner
Copy link
Contributor

caugner commented Apr 5, 2019

While investigating an issue, I noticed that the ical.js parser seems to split values that contain a comma, even if the value is quoted or the comma escaped.

This causes ICAL.stringify.component to fail on the parsed jCal object.

Update: I had a look at the ADR section in the RFC 6350:

Where it makes semantic sense, individual text components can include multiple text values (e.g., a "street" component with multiple lines) separated by the COMMA character (U+002C).

This makes me think that actually the text parsing itself is correct, but rather ICAL.stringify.property should convert the Array back into a string at this location, rather than calling ICAL.stringify._rfc6868Unescape(value) with value being an Array (that doesn't have the replace function and causes the TypeError).

Input

var input = `BEGIN:VCARD
VERSION:4.0
ADR;TYPE=home;LABEL="Test 42, Berlin":;;Test 42\, Berlin;;;;
END:VCARD
`;

var jCal = ICAL.parse(input);
console.dir(jCal);

var vcard = ICAL.stringify.component(jCal);
console.log(vcard);

Actual result

[
  "vcard",
  [
    ["version",{},"text","4.0"],
    ["adr",{"type":"home","label":["Test 42"," Berlin"]},"text",["","",["Test 42"," Berlin"],"","","",""]]],
    []
]

// Uncaught TypeError: t.replace is not a function
//     at Function.r._rfc6868Unescape (ical.js:1657)
//     at Function.r.property (ical.js:1493)
//     at Function.r.component (ical.js:1444)

Expected result

[
  "vcard",
  [
    ["version",{},"text","4.0"],
    ["adr",{"type":"home","label":"Test 42, Berlin"},"text",["","","Test 42, Berlin","","","",""]]],
    []
]

// BEGIN:VCARD
// VERSION:4.0
// ADR;TYPE=home;LABEL="Test 42, Berlin":;;Test 42\, Berlin;;;;
// END:VCARD
@caugner caugner changed the title Parser splits label and text at comma despite quoting and escaping Parser splits label at comma despite quoting Apr 5, 2019
@caugner caugner changed the title Parser splits label at comma despite quoting Parser splits ADR parameter "label" at comma despite quoting Apr 5, 2019
@caugner caugner changed the title Parser splits ADR parameter "label" at comma despite quoting Parser splits vCard ADR parameter "label" at comma despite quoting Apr 5, 2019
@caugner caugner changed the title Parser splits vCard ADR parameter "label" at comma despite quoting Parser splits vCard ADR parameter "LABEL" at comma despite quoting (when it appears after multi-value parameter "TYPE") Apr 7, 2019
@RuralYak
Copy link

@kewisch PTAL at #387

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

Successfully merging a pull request may close this issue.

2 participants