sabre-io / vobject

:date: The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects
http://sabre.io/vobject/
BSD 3-Clause "New" or "Revised" License
570 stars 125 forks source link

Allow unknown value data types for VALUE #674

Open heiglandreas opened 3 weeks ago

heiglandreas commented 3 weeks ago

Currently value-types that are not known will cause the parser to throw an InvalidDataException. In RFC5545, Section 3.2.20 is described though that the allowed values for the "VALUE" data-type can include x-names and iana-tokens. These can be any string that might - or might not - be understood by the parser. The description clearly states that "Applications MUST preserve the value data for x-name and iana-token value that they don't recognize without attempting to interpret or parse the value data"

This means that the content of the "VALUE" part should not be interpreted at all the moment the parser doesn't find a match in the corresponding mapping table.

But it should also not hard-fail when someone sets a VALUE that might not be understood. In such a case the default should be used instead.

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.78%. Comparing base (57492ab) to head (9e72aca). Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #674 +/- ## ============================================ + Coverage 98.76% 98.78% +0.02% + Complexity 1874 1873 -1 ============================================ Files 71 71 Lines 5343 5268 -75 ============================================ - Hits 5277 5204 -73 + Misses 66 64 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

heiglandreas commented 3 weeks ago

Background is a feed we got from a server that uses a DTSTAMP;VALUE=DATETIME:20240101T000000Z (note the DATETIME instead of DATE-TIME).

The whole feed looks like this:

BEGIN:VCALENDAR
PRODID;X-RICAL-TZSOURCE=TZINFO:-//Application//Calendar//EN
CALSCALE:GREGORIAN
VERSION:2.0
BEGIN:VEVENT
DTSTAMP;VALUE=DATETIME:20240101T000000Z
DTSTART;VALUE=DATE:20240910
DTEND;VALUE=DATE:20240912
UID:01234567890@example.org
SUMMARY:Summary
END:VEVENT
END:VCALENDAR

Verifying this with the ICS-Validator at https://icalendar.org/validator.html results in "Success! No errors found"

grafik

Yet with the current implementation of the library importing this feed will fail due to the unknown DATETIME value.