enesser / vCards-js

Create vCards to import contacts into Outlook, iOS, Mac OS, and Android devices from your website or application.
MIT License
419 stars 154 forks source link

Sanitize when read vcard #29

Open mariohmol opened 6 years ago

mariohmol commented 6 years ago

HI,

i'm reading some files from outlook and i had to make some changes to work, see if that makes sense to incorporate some how

          let ediFileContent = fs.readFileSync(fileFound).toString();
          ediFileContent = ediFileContent.replace('begin:vcard', 'BEGIN:VCARD')
            .replace('end:vcard', 'END:VCARD');
          ediFileContent = ediFileContent.split('\n').map(p => {
            const arr = p.split(':');
            arr[0] = arr[0].toUpperCase().replace(';CHARSET=UTF-8', '');
            return arr.join(':');
          }).join('\n');

This is the original vcf:


begin:vcard
version:3.0
prodid:Microsoft-MacOutlook/f.17.0.160611
UID:D35EB00C-0C8E-4781-8E9C-372B0E2957D1
fn;charset=utf-8:Joao Mendes
n;charset=utf-8:Mendes;Joao;;;
title;charset=utf-8:Pré-venda
note;charset=utf-8:Grup.\n\n\n\n\n\n\n\n\n
tel;charset=utf-8;type=cell:99999-1326
end:vcard 
enesser commented 5 years ago

Thanks for reporting. Will have to look into this.