Skip to content

Duplicate TZID in VTIMEZONE crashes from_ical with AttributeError ('list' object has no attribute 'strip') #2111

Open

Description

@rahul05ranjan

Duplicate TZID line in a VTIMEZONE crashes parsing with AttributeError ('list' object has no attribute 'strip')

A calendar with a repeated TZID property inside the same VTIMEZONE (easy to produce with a broken or hand-edited generator) makes Calendar.from_ical() die with an AttributeError deep inside the timezone cache instead of a parse error:

>>> from icalendar import Calendar
>>> ics = """BEGIN:VCALENDAR
... VERSION:2.0
... PRODID:-//Test//EN
... BEGIN:VTIMEZONE
... TZID:Europe/Berlin
... TZID:Europe/Berlin
... BEGIN:STANDARD
... DTSTART:19701025T030000
... RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
... TZNAME:CET
... TZOFFSETFROM:+0200
... TZOFFSETTO:+0100
... END:STANDARD
... END:VTIMEZONE
... END:VCALENDAR
... """
>>> Calendar.from_ical(ics)
Traceback (most recent call last):
  ...
  File ".../icalendar/parser/ical/component.py", line 145, in handle_end_component
    tzp.cache_timezone_component(component)
  File ".../icalendar/timezone/tzp.py", line 145, in cache_timezone_component
    _id = self.clean_timezone_id(_unclean_id)
  File ".../icalendar/timezone/tzp.py", line 170, in clean_timezone_id
    return tzid.strip("/")
AttributeError: 'list' object has no attribute 'strip'

Expected

from_ical() should either accept the (duplicate) definition or raise a normal parsing error (ICalParsingError/ValueError) — not an AttributeError from the timezone machinery.

What happens

With two TZID lines the component's TZID value becomes a list (two entries), and cache_timezone_component() passes that list into clean_timezone_id(), which calls tzid.strip("/") (src/icalendar/timezone/tzp.py:170) assuming a string. Anything that reads .ics text from untrusted/legacy sources hits this as a hard crash. Verified on main at ed63cc0, found by mutation fuzzing of a valid calendar. A type guard in clean_timezone_id (take tzid[0] / reject non-strings) or using the component's documented single-value access would fix it.

Activity

  1. github-actions commented on Nov 14, 2026

    @github-actions
    Contributor

    Thanks for the issue, @rahul05ranjan! A maintainer will review it shortly.

  2. github-actions commented on Nov 14, 2026

    @github-actions
    Contributor

    Mixed activity

    Activity patterns show a mix of organic and automated signals.

    View full analysis →

    Evidence
    • Multiple forks: 6 repositories forked in a single 24-hour window
    • 24/7 activity pattern: Active in 22 of 24 hours, with the longest break being only 2.2 hours

    Last 5 PRs:

    This is an automated analysis by AgentScan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentscan:needs-reviewAgentScan flagged this item for review because it has mixed signals

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions