collective / icalendar

icalendar parser library for Python
https://icalendar.readthedocs.io
Other
990 stars 171 forks source link

[BUG] deviation from the standard "classification" allowed values and X- values #736

Closed BMaxV closed 2 days ago

BMaxV commented 2 days ago

Hello everyone!

Thanks for making this software, I found a minor thing that's potentially a bit annoying because it prevents me from using custom values.

I can of course always work around it by putting it into the summary or something, as text, but that's obviously not ideal.

The official validator didn't mind me putting in seemingly arbitrary values. I'm not sure if that's intentional.

Describe the bug

The .calendar_from_ics and the Todo object constructor (?) don't accept my arbitrary classification "HERPADERPA" as a possible / valid value for classification. But the official validator, does.

https://icalendar.org/iCalendar-RFC-5545/3-8-1-3-classification.html

It doesn't look like you allow the IANA and X-types.

value is not a valid enumeration member; permitted: 'PUBLIC', 'PRIVATE', 'CONFIDENTIAL' (type=type_error.enum; enum_values=[<Classification.PUBLIC: 'PUBLIC'>, <Classification.PRIVATE: 'PRIVATE'>, <Classification.CONFIDENTIAL: 'CONFIDENTIAL'>])

I'm not actually sure how the "X-" values are supposed to be defined. But the official validator didn't complain.

To Reproduce

Go to the validtor, plug it in and observe the result.

https://icalendar.org/validator.html

BEGIN:VCALENDAR
PRODID:-//github.com/allenporter/ical//8.2.0//EN
VERSION:2.0
BEGIN:VTODO
UID:20070313T123432Z-456553@example.com
DTSTAMP:20250313T123432Z
DUE;VALUE=DATE:20070501
SUMMARY:Submit Quebec Income Tax Return for 2006
CLASS:CONFIDENTIAL,HERPADERPA
CATEGORIES:FAMILY,FINANCE
X-HER-PADERPA:foobar
STATUS:NEEDS-ACTION
END:VTODO
END:VCALENDAR

alternatively, run this code, observe that it fails.

from ical.calendar import Calendar
from ical.calendar_stream import IcsCalendarStream

s="""
BEGIN:VCALENDAR
PRODID:-//github.com/allenporter/ical//8.2.0//EN
VERSION:2.0
BEGIN:VTODO
UID:20070313T123432Z-456553@example.com
DTSTAMP:20250313T123432Z
DUE;VALUE=DATE:20070501
SUMMARY:Submit Quebec Income Tax Return for 2006
CLASS:CONFIDENTIAL,X-HERPA;VALUE=foo:bar
CATEGORIES:FAMILY,FINANCE
X-HER-PADERPA:foobar
STATUS:NEEDS-ACTION
END:VTODO
END:VCALENDAR
"""
calendar = IcsCalendarStream.calendar_from_ics(s)

Expected behavior

Environment

Additional context

That did not work

pip3 install https://github.com/collective/icalendar.git
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting https://github.com/collective/icalendar.git

  Downloading https://github.com/collective/icalendar.git
     \ 394.3 kB 5.9 MB/s 0:00:00
  ERROR: Cannot unpack file /tmp/pip-unpack-egvpldnx/icalendar.git (downloaded from /tmp/pip-req-build-uw1ezop4, content-type: text/html; charset=utf-8); cannot detect archive format
ERROR: Cannot determine archive format of /tmp/pip-req-build-uw1ezop4
niccokunzmann commented 2 days ago

Hi, this module is called

import icalendar

Could you check if you are in the right issue tracker? You are welcome to use this module of cause.

BMaxV commented 2 days ago

Thank you, you are completely right, this is the wrong bugtracker.

Thanks!