Skip to content

[Bug] Regression in ATTACH parsing? #1299

@kmurphy4

Description

@kmurphy4

Hi! I'm trying to upgrade from v6 to v7, and I noticed a change in behavior related to ATTACH parsing - I'm now seeing a vBinary component in a situation where I previously saw a vUri.

To reproduce

import icalendar

data = b"""
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:19960704T120000Z
UID:uid1@example.com
ORGANIZER:mailto:jsmith@example.com
DTSTART:19960918T143000Z
DTEND:19960920T220000Z
STATUS:CONFIRMED
CATEGORIES:CONFERENCE
SUMMARY:Summary
DESCRIPTION:Description
ATTACH;VALUE=BINARY;ENCODING=BASE64;X-FILENAME=image.png:
 bm90IGEgcmVhbCBwbmcgYnV0IHNob3VsZG4ndCBtYXR0ZXIuLg==
END:VEVENT
END:VCALENDAR
"""

ical = icalendar.Calendar.from_ical(data)
print(ical)

attach = ical.subcomponents[0]["ATTACH"]
print(type(attach))

Output:

With icalendar==6.3.2 this produced

VCALENDAR({'VERSION': vText(b'2.0')}, VEVENT({'DTSTAMP': vDDDTypes(1996-07-04 12:00:00+00:00, Parameters({})), 'UID': vText(b'uid1@example.com'), 'ORGANIZER': vCalAddress('mailto:jsmith@example.com'), 'DTSTART': vDDDTypes(1996-09-18 14:30:00+00:00, Parameters({})), 'DTEND': vDDDTypes(1996-09-20 22:00:00+00:00, Parameters({})), 'STATUS': vText(b'CONFIRMED'), 'CATEGORIES': <icalendar.prop.vCategory object at 0x73ffd5abe4b0>, 'SUMMARY': vText(b'Summary'), 'DESCRIPTION': vText(b'Description'), 'ATTACH': 'bm90IGEgcmVhbCBwbmcgYnV0IHNob3VsZG4ndCBtYXR0ZXIuLg=='}))
<class 'icalendar.prop.vUri'>

but with icalendar==7.0.3 it produces

VCALENDAR({'VERSION': vText(b'2.0')}, VEVENT({'DTSTAMP': vDDDTypes(1996-07-04 12:00:00+00:00, Parameters({})), 'UID': vText(b'uid1@example.com'), 'ORGANIZER': vCalAddress('mailto:jsmith@example.com'), 'DTSTART': vDDDTypes(1996-09-18 14:30:00+00:00, Parameters({})), 'DTEND': vDDDTypes(1996-09-20 22:00:00+00:00, Parameters({})), 'STATUS': vText(b'CONFIRMED'), 'CATEGORIES': vCategory([vText(b'CONFERENCE')], params=Parameters({})), 'SUMMARY': vText(b'Summary'), 'DESCRIPTION': vText(b'Description'), 'ATTACH': vBinary(b'bm90IGEgcmVhbCBwbmcgYnV0IHNob3VsZG4ndCBtYXR0ZXIuLg==')}))
<class 'icalendar.prop.binary.vBinary'>

Environment

  • Operating system: ubuntu 22.04
  • Python version: 3.12.12
  • icalendar version: 6.3.2 and 7.0.3

Additional context

  • I tested it with the latest version. For example, I used the command pip3 install --upgrade https://github.com/collective/icalendar.git.
  • I attached the .ics sample file example.ics.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions