Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 350 #616

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ New features:

Bug fixes:

- ...
- Parse calendars with X-COMMENT properties at the end the file by ignoring these properites


5.0.12 (2024-03-19)
Expand Down
2 changes: 1 addition & 1 deletion docs/credits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ icalendar contributors
- Michał Górny <mgorny@gentoo.org>
- Pronoy <lukex9442@gmail.com>
- Abe Hanoka <abe@habet.dev>
- `Natasha Mattson <https://github.com/natashamm`_
- `Natasha Mattson <https://github.com/natashamm>`_
- `NikEasY <https://github.com/NikEasY>`_
- Matt Lewis <git@semiprime.com>
- Felix Stupp <felix.stupp@banananet.work>
Expand Down
7 changes: 6 additions & 1 deletion src/icalendar/cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,12 @@ def from_ical(cls, st, multiple=False):
factory = types_factory.for_property(name)
component = stack[-1] if stack else None
if not component:
raise ValueError(f'Property "{name}" does not have a parent component.')
# only accept X-COMMENT at the end of the .ics file
# ignore these components in parsing
if uname == 'X-COMMENT':
break
else:
raise ValueError(f'Property "{name}" does not have a parent component.')
datetime_names = ('DTSTART', 'DTEND', 'RECURRENCE-ID', 'DUE',
'RDATE', 'EXDATE')
try:
Expand Down
36 changes: 36 additions & 0 deletions src/icalendar/tests/calendars/issue_350.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Podio API//EN//view-exporter//52593453
METHOD:REQUEST
X-WR-CALNAME:view52593586
X-WR-TIMEZONE:Europe/Berlin
CALSCALE:GREGORIAN
X-COMMENT-USAGE:This calendar does not contain recurring events!
X-COMMENT-GENERATOR:PHP Version 8.0.16
BEGIN:VEVENT
STATUS:CONFIRMED
SEQUENCE:0
TRANSP:OPAQUE
CLASS:PUBLIC
UID:20055546456446
SUMMARY:Termin 4353 und"so"
DESCRIPTION;ALTREP="data:text/html,%3Cbody%3E%3Cp%3EToller%20%3Cstron
g%20class%3D%22text-bold%22%3ETermin%3C%2Fstrong%3E%20f%C3%BCr%3C%2Fp
%3E%3Cblockquote%3E%3Cp%3Emal%20%3Cem%20class%3D%22text-italic%22%3Ez
u%22gucken%22%3C%2Fem%3E%3C%2Fp%3E%3C%2Fblockquote%3E%3Cp%3E%3Cu%20cl
ass%3D%22text-underline%22%3Eund%3C%2Fu%3E%20%3Cdel%3Eso%3C%2Fdel%3E%
3Cbr%2F%3E%3C%2Fp%3E%3C%2Fbody%3E":Toller Termin fürmal zu\"gucken\"
und so
X-ALT-DESC;FMTTYPE=text/html:<html><head></head><body><p>Toller <stro
ng class="text-bold">Termin</strong> für</p><blockquote><p>mal <em c
lass="text-italic">zu"gucken"</em></p></blockquote><p><u class="text-
underline">und</u> <del>so</del><br/></p></body></html>
URL:https://podio.com/xxxxxxyyyyyy/zpodio-testgelande/apps/calen
dar/items/5
LOCATION:online
DTSTART:20220222T183000Z
DTEND:20220222T193000Z
DTSTAMP:20220220T142821Z
END:VEVENT
END:VCALENDAR
X-COMMENT:Cached from 2022-02-20 14:28:21 - new at most every 1800sec.
9 changes: 9 additions & 0 deletions src/icalendar/tests/test_issue_350.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'''Issue #350 - Ignore X-... properties also at end of file?

https://github.com/collective/icalendar/issues/350
'''
from icalendar import Calendar

def test_issue_350(calendars):
calendar = list(calendars.issue_350.walk('X-COMMENT'))
assert len(calendar) == 0, "X-COMMENT at the end of the file was parsed"