mangstadt/ez-vcard

Address field parsing issue

Closed this issue · 2 comments

I am using latest version of ez-vcard 'com.googlecode.ez-vcard:ez-vcard:0.11.2' on my Android app.

Using this, if we parse the attached vcard(no personal data present), it is throwing the following exception

java.lang.IllegalArgumentException: Property "ADR" has a parameter named "LABEL" whose value contains one or more invalid characters. The following characters are not permitted: [ \n \r " ]
at com.github.mangstadt.vinnie.io.VObjectWriter.validate(VObjectWriter.java:617)
at com.github.mangstadt.vinnie.io.VObjectWriter.writeProperty(VObjectWriter.java:465)
at ezvcard.io.text.VCardWriter._write(VCardWriter.java:334)
at ezvcard.io.StreamWriter.write(StreamWriter.java:69)
at ezvcard.io.chain.ChainingTextWriter.go(ChainingTextWriter.java:253)
at ezvcard.io.chain.ChainingTextWriter.go(ChainingTextWriter.java:228)
at ezvcard.io.chain.ChainingTextWriter.go(ChainingTextWriter.java:180)
at ezvcard.VCard.write(VCard.java:166)

Zipped the vcard file as github doesn't like plain vcf files uploaded.
contacts-nextcloud-download.vcf.zip

Also, here is another app using the same library and facing same issue
https://forums.bitfire.at/topic/1078/support-for-values-with-double-quotes-and-newlines-rfc-6868/4

I was able to parse the attached vCard on my end without issue.

The stack trace suggests that the error is occurring while you are writing a vCard, not reading one.

Your vCard contains an escaped double-quote character at the end of the LABEL parameter value. This escaping protocol is defined separately from the vCard spec, and is disabled by default when writing vCards using ez-vcard. You must tell ez-vcard to enable this escaping protocol if you want to include double-quote characters in parameter values:

String str = Ezvcard.write(vcard).caretEncoding(true).go();

@mangstadt Yup, I realize now that in our app, once I read the entire vcard file, I start to write vcard strings to database for each contact and is breaking there. The above line mentioned has fixed the issue.

Thanks for the quick reply. Have a good day. Closing this issue.