Comments (4)
Hi Peter,
ez-vcard logs the invalid version number as a parse warning, and then treats it as an extended (custom) property:
List<List<ParseWarning>> warnings = new ArrayList<>();
Path path = Paths.get("peter.vcf");
VCard vcard = Ezvcard.parse(path).warnings(warnings).first();
System.out.println(vcard.getExtendedProperty("VERSION").getValue());
System.out.println(warnings);
Outputs:
1.0
[[Line 2 (VERSION property): (27) Skipped. Unknown version number found. Treating it as a regular property. The entire line is: "VERSION:1.0"]]
Regards,
Mike
from ez-vcard.
From Peter via email:
Hi Mike,
thank you very much for your support. Your solution works fine for me, however, I’am still struggling with the version property…
When Property VERSION is absent, neither a parse warning nor a validation warning is issued.
Please see this example:
BEGIN:VCARD
N;LANGUAGE=en:Doe;John
FN:John Doe
ORG:Big Company
TITLE:Boss
TEL;WORK;VOICE:0123456789
X-MS-OL-DEFAULT-POSTAL-ADDRESS:0
EMAIL;PREF;INTERNET:[email protected]
REV:20231122T151319Z
END:VCARD
Using Ezvcard.parse(path).warnings(warnings).first() the list of warnings is empty.
Using ValidationWarnings = Ezvcard.parse(path).first().validate(vcardVersion) the ValidationWarnings object is empty too.
vcard.getExtendedProperty("VERSION") return a NULL value when property VERSION is absent but it also returns a NULL value, when property VERSION is set to a proper value, e.g. “2.1”. So this method is not useful too.
Would you please check again? Is there any possibility to check if property VERSION is provided at all?
Kind regards
Peter
from ez-vcard.
Hi Peter,
There is currently no direct way of detecting whether a VERSION property is missing from a vCard.
As a workaround, you could parse the vCard twice using different default versions and compare the versions of the parsed vCards.
Path path = Paths.get("peter.vcf");
VCardVersion v1;
try (VCardReader reader = new VCardReader(path, VCardVersion.V2_1)) {
VCard vcard = reader.readNext();
v1 = vcard.getVersion();
}
VCardVersion v2;
try (VCardReader reader = new VCardReader(path, VCardVersion.V3_0)) {
VCard vcard = reader.readNext();
v2 = vcard.getVersion();
}
boolean versionPropertyIsMissing = (v1 != v2);
Regards,
Mike
from ez-vcard.
From Peter via email:
Hi Mike,
thank you very much for your code example. The workaround is great! I have checked the functionality within my application. Now everything is fine.
Kind regards
Peter
from ez-vcard.
Related Issues (20)
- VCardWriter - Writes data without proper formatting for Google Contacts - Expected : YYYY-MM-DD ; current : YYYYMMDD HOT 2
- [Q] How do I get the `RawProperty`s? HOT 1
- Version 0.11.3 vulnerabilities HOT 3
- Migration to 0.12.0 while still supporting Android API 21..25 HOT 6
- Add support for Jigsaw modules HOT 1
- Parsing from chunk of text HOT 2
- Custom getter in VCardProperty HOT 9
- Invalid value for "MonthOfYear" caused by wrong BDAY date HOT 1
- Raw property values HOT 4
- Relations and Anniversaries are lost in serialization HOT 2
- what is the way to add social media contact? HOT 1
- Default line folding line length is not null HOT 1
- [Compatibility] Treat KIND values case-insensitive HOT 2
- whole vCard being drop instead of the specific corrupted fields HOT 3
- WhatsApp format of vcard is not supported?
- No Class found in DavX5 HOT 1
- hCard GEO HOT 1
- CRLF is handled incorrectly in vcard 2.1 properties HOT 8
- vCard.toList() (VCardProperty) list in return empty on release version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ez-vcard.