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

parsing error when trying to process multiple vcard entries that was exported from icloud #35

Closed
hqtsky opened this issue Oct 11, 2019 · 2 comments

Comments

@hqtsky
Copy link

hqtsky commented Oct 11, 2019

I exported a set of contacts from my icloud.com account. This file appears to be correct but when importing using the multiple imports method I get this error:

SyntaxError: Invalid vCard: Expected "VERSION:\d.\d" but found "undefined"

Here is how read and import the file:

var contactData = fs.readFileSync("./samples/multiple-contacts-from-icloud.vcf","utf8", "utf8");
var contacts = vCard.parse(contactData); //multiple

I've attached my sample file here, i appended the '.txt' extension to allow attach here.
multiple-contacts-from-icloud.vcf.txt

@hqtsky
Copy link
Author

hqtsky commented Oct 11, 2019

I suspected that Apple/iCloud file export only used newline ascii 10 or x0A. So i replaced it with the carriage return, newline.. I wonder if this could be added to the normalize() sequence.
contactData = contactData.replace(new RegExp(String.fromCharCode(10), 'g'), '\r\n');

@jhermsmeier
Copy link
Owner

Thanks, but due to #31 we cannot add this to the normalization, as also further touched on in #34 (comment). TLDR; it breaks other things. So unfortunately users of this module will have to replace LF -> CRLF themselves, if they know it is safe to do so.

I suspected that Apple/iCloud file export only used newline ascii 10 or x0A.

I'd think that it would emit a VCF file with CRLF, but have never tested it. Could also be that a text editor automatically translated CRLF -> LF, if you opened the file in one by any chance? (That seems to be a common occurrence)

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

No branches or pull requests

2 participants