mangstadt / ez-vcard

A vCard parser library for Java
Other
405 stars 93 forks source link

whole vCard being drop instead of the specific corrupted fields #142

Closed HaimMichalashvili closed 1 year ago

HaimMichalashvili commented 1 year ago

Hello everyone,

I'm having trouble parsing a raw text vCard. Here's the vCard:

BEGIN:VCARD
VERSION:3.0
PRODID:-//16.3.0//Android
N:2 Babu vai;;;;
FN:2 Babu vai
TEL;TYPE=Mobile:+8801711366225
BDAY;value=date:00000000
END:VCARD

Unfortunately, an exception was thrown and the package did not handle it. The error message was: "java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0".

I understand that 00000000 is not a valid date type, but my concern is that I cannot get a parsed Vcard object with valid fields such as N, FN, TEL, etc. (at least saving the valid fields)

To parse, Im using the code below: vcard = vCardReader.readNext();

After debugging the package, I discovered that the exception was thrown from the file called VCardDateFormat.class, specifically on line 72: LocalDate date = LocalDate.of(p.year(), p.month(), p.date()); (The exception has not been handled)

related to: [https://github.com/mangstadt/ez-vcard/issues/134#issue-1743648284]()

Any help would be greatly appreciated.

HaimMichalashvili commented 1 year ago

I just wanted to express my gratitude for this commit that saved my day!

https://github.com/mangstadt/ez-vcard/commit/4b978e8cba83996502e1dead43368c8b7d26ecac

Even though the fix hasn't been released yet, I was able to download and pack the jar and manually add it to my project's pom.

Thank you so much for your help!

mangstadt commented 1 year ago

Glad you got it working!

See also: https://github.com/mangstadt/ez-vcard/issues/134

mangstadt commented 1 year ago

ez-vcard version 0.12.1 has been released, which includes this bug fix!