cozy / cozy-vcard

Cozy-vcard provides vcard Parser and Objects
Other
29 stars 17 forks source link

multi contacts in vcard #29

Closed enguerran closed 4 years ago

enguerran commented 6 years ago

While I was writing worry #28 I realized another bug:

When I parse a single vcard with a phone number and a label:

BEGIN:VCARD
VERSION:3.0
FN:Tel Label Work
N:Label Work;Tel;;;
TEL;TYPE=WORK:0987 65 43 21
item1.ADR:;;;;;;
item1.X-ABLabel:
END:VCARD

I receive:

[
  {
    "datapoints": [
      { "name": "tel", "type": "work", "value": "0987 65 43 21" },
      { "name": "adr", "value": ["", "", "", "", "", "", ""] }
    ],
    "fn": "Tel Label Work",
    "n": "Label Work;Tel;;;"
  }
]

But when I parse a multi contacts vcard:

BEGIN:VCARD
VERSION:3.0
FN:Tel Label Other
N:Label Other;Tel;;;
TEL:1019181716
item1.ADR:;;;;;;
item1.X-ABLabel:
END:VCARD
BEGIN:VCARD
VERSION:3.0
FN:Tel Label Work
N:Label Work;Tel;;;
TEL;TYPE=WORK:0987654321
item1.ADR:;;;;;;
item1.X-ABLabel:
END:VCARD
BEGIN:VCARD
VERSION:3.0
FN:Tel No Label
N:No Label;Tel;;;
item1.TEL:0123456789
item1.X-ABLabel:
item2.ADR:;;;;;;
item2.X-ABLabel:
END:VCARD
BEGIN:VCARD
VERSION:3.0
FN:Tels One Label One Other One Not
N:One Label One Other One Not;Tels;;;
item1.TEL:0102030405
item1.X-ABLabel:
TEL;TYPE=WORK:0908070605
TEL:19181717
item2.ADR:;;;;;;
item2.X-ABLabel:
END:VCARD

The json does not contain the phone number for the label WORK

[
  {
    "datapoints": [{ "name": "adr", "value": ["", "", "", "", "", "", ""] }],
    "fn": "Tel Label Other",
    "n": "Label Other;Tel;;;"
  },
  {
    "datapoints": [
      { "name": "adr", "type": "work", "value": ["", "", "", "", "", "", ""] }
    ],
    "fn": "Tel Label Work",
    "n": "Label Work;Tel;;;"
  },
  {
    "datapoints": [
      { "name": "tel", "value": "0123456789" },
      { "name": "adr", "value": ["", "", "", "", "", "", ""] }
    ],
    "fn": "Tel No Label",
    "n": "No Label;Tel;;;"
  },
  {
    "datapoints": [
      { "name": "tel", "value": "0102030405" },
      { "name": "tel", "type": "work", "value": "0908070605" },
      { "name": "adr", "value": ["", "", "", "", "", "", ""] }
    ],
    "fn": "Tels One Label One Other One Not",
    "n": "One Label One Other One Not;Tels;;;"
  }
]