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

vCard 2.1 Addresses Formatted Incorrectly #30

Open mdw19873 opened 5 years ago

mdw19873 commented 5 years ago

We have an odd scenario where we need to support vCard 2.1, however, we've discovered a formatting issue with it on newer phones. In cases where we specify format 2.1, the label for the address shows as CHARSET. Upon further investigation, I discovered you format the ADR field exactly the same for 2.1 as you do for 3.0. This is making the phones pickup the label as the defined charset and not the type as specified or ignoring the field all together.

It took some digging, but I did find the original 2.1 specification with an example:

Delivery Addressing Properties Delivery Address This property specifies a structured representation of the physical delivery address for the vCard object. The property is made up of components that are based on the X.500 Post Office Box attribute, the X.520 Street Address geographical attribute, the X.520 Locality Name geographical attribute, the X.520 State or Province Name geographical attribute, the X.520 Postal Code attribute, and the X.520 Country Name geographical attribute. This property is identified by the property name ADR. The property value consists of components of the address specified as positional fields separated by the Field Delimiter character (ASCII decimal 59). The property value is a concatenation of the Post Office Address (first field) Extended Address (second field), Street (third field), Locality (fourth field), Region (fifth field), Postal Code (six field), and Country (seventh field) strings. An example of this property follows: ADR;DOM;HOME:P.O. Box 101;Suite 101;123 Main Street;Any Town;CA;91921-1234; Support for this property is optional for vCard Writers conforming to this specification. Delivery Address Type This property parameter specifies the sub-types of physical delivery that is associated with the delivery address. For example, the label may need to be differentiated for Home, Work, Parcel, Postal, Domestic, and International physical delivery. One or more sub-types can be specified for a given delivery address. The property parameter can have one or more of the following values: Description Property Parameter Value TYPE= Indicates a domestic address DOM Indicates an international address (Default) INTL Indicates a postal delivery address (Default) POSTAL Indicates a parcel delivery address (Default) PARCEL Indicates a home delivery address HOME Indicates a work delivery address (Default) WORK

While it does say that you can specify TYPE=, modern Android and iPhones do not seem to pick up on this. The few examples I've found across the internet have also favored the type as the second field for ADR and omits the TYPE=