Skip to content

Bound the expansion of timezone changes; fixes #1054 - #1055

Open
mkmelin wants to merge 1 commit into
kewisch:mainfrom
mkmelin:bad-vtimezone-rrule
Open

mkmelin wants to merge 1 commit into
kewisch:mainfrom
mkmelin:bad-vtimezone-rrule

Conversation

@mkmelin

@mkmelin mkmelin commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Timezone._expandComponent only stopped expanding a STANDARD/DAYLIGHT rule at the coverage year. A sub-daily rule, or one whose BY* parts expand into many instances, made any conversion in that zone run practically forever.

  • Only the DTSTART of a SECONDLY, MINUTELY or HOURLY rule is used. Real timezones never change more often than daily.
  • Expansion stops once a timezone has Timezone.MAX_CHANGES (10000) changes. Real zones need far fewer, even starting from 1601.
  • _ensureCoverage now clears changes before re-expanding. Each expansion starts over from DTSTART, so extending the coverage to a later year used to append a second copy of every change. Without this, the duplicates would also count against the limit.

The new tests hang without the fix.

`Timezone._expandComponent` only stopped expanding a STANDARD/DAYLIGHT rule at the coverage year. A sub-daily rule, or one whose BY* parts expand into many instances, made any conversion in that zone run practically forever.

- A SECONDLY, MINUTELY or HOURLY rule only contributes its DTSTART, taken directly without running the recurrence iterator. Real timezones never change more often than daily.
- Expansion stops once a timezone has `Timezone.MAX_CHANGES` (10000) changes. Real zones need far fewer, even starting from 1601.
- `_ensureCoverage` now clears `changes` before re-expanding. Each expansion starts over from DTSTART, so extending the coverage to a later year used to append a second copy of every change. Without this, the duplicates would also count against the limit.

The new tests hang without the fix.
@mkmelin
mkmelin force-pushed the bad-vtimezone-rrule branch from 449be47 to e71b0b1 Compare October 15, 2026 10:37

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unbounded VTIMEZONE expansion with sub-daily RRULE hangs timezone conversion

1 participant