emersion / go-vcard

A Go library to parse and format vCard
MIT License
107 stars 34 forks source link

`ENCODING=QUOTED-PRINTABLE` unsupported #32

Open Peltoche opened 5 months ago

Peltoche commented 5 months ago

Hi, first of all thanks for you lib.

I have exported my contacts from the default contact app on an android phone (lineagos 21 enchiladas) and each time a field have an accent or a non-ascii character the file with have its content formatted as follow:

TITLE;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=4B=69=6E=C3=A9=73=69=74=68=C3=A9=72=61=70=65=75=74=65

For example this field TITLE field contains Kinésithérapeute as value. As you have probably guessed, when I parse it with you lib it will print directly the content without decoding.

The RFC6350 section 3.1 make a reference to the RFC3536 which have a reference to the QUOTED-PRINTABLE notation.

emersion commented 5 months ago

Section 3.1 just says that the charset (a concept defined in RFC 3536) is always UTF-8. It does not define any parameter to change this, nor does it define any parameter to set the encoding.

ENCODING is defined for vCard v3: https://www.rfc-editor.org/rfc/rfc2425.html#section-5.8.3 (but QUOTED-PRINTABLE is not a proper value)

vCard v3 states, in the section "Differences From vCard v2.1": "The VCARD CHARSET type parameter has been eliminated. Character set can only be specified on the CHARSET parameter on the Content-Type MIME header field."

Are you trying to read vCard 2 files?

Peltoche commented 5 months ago

Erf, yep indeed. The file have a V2 header. Do you plan to support it or this is out of your project scope ?

emersion commented 5 months ago

So far I've been trying to avoid supporting vCard 2, because it's a lot more complex and ill-defined. Would need more investigation to figure out exactly what vCard 2 support would entail (see https://datatracker.ietf.org/doc/html/rfc2426#section-5).

Most likely the best way to implement it without introducing complexity all over the place would be to extend ToV4 to support vCard 2.