kewisch/ical.js

Parsing vCards adds additional quotation marks in TYPE atributes

5ila5 opened this issue · 3 comments

5ila5 commented
var vCard = "BEGIN:VCARD\nVERSION:3.0\nPRODID:-//Apple Inc.//iOS 13.3//EN\nN:Doe;John;;;\nFN:John Doe\nEMAIL;type=INTERNET;type=HOME;type=pref:John_Doer@example.com\nTEL;type=CELL;type=VOICE;type=pref:+49 123 4567890\nitem1.ADR;type=HOME;type=pref:;;street 2A;MyCity;MyState;83465;Deutschl\n and\nBDAY;value=date:1900-01-01\nREV:2020-01-17T10:34:14Z\nX-IMAGEHASH:qYML1ZJqQnL6FyrmNWNsWw==\nEND:VCARD"


var jcalData = ICAL.parse(vCard);
vCard = new ICAL.Component(jcalData)
console.log(vCard.toString())

returns

BEGIN:VCARD
VERSION:3.0
PRODID;VALUE=TEXT:-//Apple Inc.//iOS 13.3//EN
N:Doe;John;;;
FN:John Doe
EMAIL;TYPE="INTERNET,HOME,pref":John_Doer@example.com
TEL;TYPE="CELL,VOICE,pref";VALUE=PHONE-NUMBER:+49 123 4567890
ITEM1.ADR;TYPE="HOME,pref":;;street 2A;MyCity;MyState;83465;Deutschland
BDAY;VALUE=DATE:19000101
REV;VALUE=DATE-TIME:20200117T103414Z
X-IMAGEHASH:qYML1ZJqQnL6FyrmNWNsWw==
END:VCARD

Which has quotation marks for the Type parameter of EMAIL an TEL
I encountered this because i wanted to diagnose an error with Nextcloud where CardDav would display additional quotation marks
nextcloud/server#25485
nextcloud/contacts#2866

I had this issue only when importing where this library is Used:
https://github.com/nextcloud/contacts/blob/5fd5d688d93d65b1079906e92eb31da65917b98d/src/models/contact.js#L61-L72

Edited:
the above code is called in followed by
vCard.toString()
https://github.com/nextcloud/contacts/blob/5fd5d688d93d65b1079906e92eb31da65917b98d/src/store/addressbooks.js#L410-L424

@kewisch Does this make sense?

AFAICT, properties that need every value quoted have URI values and therefore get quoted because of the :, and properties that don't the only possible values are simple strings (cell, voice, internet) etc. and wouldn't get quoted. Is there some case I'm missing?

@darktrojan Can we close this given #555 is merged?

It looks like we haven't heard back on this issue, therefore we are closing this issue. If this problem persists in the latest version of ical.js, please re-open this issue.