Skip to content

Commit

Permalink
Merge pull request #616 from natashamm/issue_350
Browse files Browse the repository at this point in the history
Issue 350
  • Loading branch information
niccokunzmann authored May 20, 2024
2 parents 798ee4a + 23285c0 commit 9e3b686
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
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"

0 comments on commit 9e3b686

Please sign in to comment.