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 with icloud.com vcf fail #1

Open
lionep opened this issue Oct 17, 2023 · 2 comments
Open

Parsing with icloud.com vcf fail #1

lionep opened this issue Oct 17, 2023 · 2 comments

Comments

@lionep
Copy link

lionep commented Oct 17, 2023

Hello,

Thanks for this project.
I succesfully parsed iOS 17 vcf file directly with parseVCards method, but the same contact list from icloud.com has a difference.

On iOS 17 :
new lines of vcf file are : \r\n

On iCloud.com
new lines of vcf file are : \n

Parsing of icloud.com vcf file results in every data in the "VERSION field"

{
  VERSION: [
    {
      VALUE: '3.0\n' +
        'PRODID:-//Apple Inc.//iOS 17.0.2//EN\n' +
        'N:Name;Name;;;\n' +
        'FN:Name Name\n' +
        'EMAIL;type=INTERNET;type=WORK;type=pref:nname@example.com\n' +
        'item1.EMAIL;type=INTERNET:nname@example2.com\n' +
        'X-SHARED-PHOTO-DISPLAY-PREF:AUTOUPDATE\n' +
        'REV:2023-10-04T11:32:44Z\n' +
        'X-IMAGETYPE:PHOTO\n' +
        'X-IMAGEHASH:AAAAAA+AAAAAA=='
    }
  ]
}

instead of

{
  VERSION: [ { VALUE: '3.0' } ],
  PRODID: [ { VALUE: '-//Apple Inc.//iOS 17.0.2//E=:Name;Name;;;' } ],
  FN: [ { VALUE: 'Name Name' } ],
  EMAIL: [ { type: 'pref', VALUE: 'nname@example.com' } ],
  'item1.EMAIL': [ { type: 'INTERNET', VALUE: 'nname@example2.com' } ],
  'X-SHARED-PHOTO-DISPLAY-PREF': [ { VALUE: 'AUTOUPDATE' } ],
  REV: [ { VALUE: '2023-10-04T11:32:44Z' } ],
  'X-IMAGETYPE': [ { VALUE: 'PHOTO' } ],
  'X-IMAGEHASH': [ { VALUE: 'AAAAAA+AAAAAA==' } ]
}

As a workaroud, I used :

let vcards = parseVCards(file.buffer.toString());

// Check if \n instead of \r\n
if (vcards?.length > 0 && Object.keys(vcards[0]).length === 1 && vcards[0].VERSION) {
  vcards = parseVCards(file.buffer.toString().replace(/\n/g, '\r\n'));
}
@AndrewLauu
Copy link
Owner

Thank you for using this small tool, as it's so poorly developed🤣
I'll check it out ASAP😃

@lionep
Copy link
Author

lionep commented Oct 21, 2023

Sorry I didn’t update, but I finally used vcf.
It has the same icloud issue, but I used the same fix.

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