mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-22 18:11:17 +00:00
Compare commits
2 Commits
feat/calda
...
ba0450d0aa
| Author | SHA1 | Date | |
|---|---|---|---|
|
ba0450d0aa
|
|||
|
d7d8dba2de
|
@@ -14,13 +14,6 @@ export interface ICalTimeRange {
|
|||||||
end: Date
|
end: Date
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Safety cap to prevent runaway iteration on pathological recurrence rules.
|
|
||||||
* Each iteration is pure date math (no I/O), so a high cap is fine.
|
|
||||||
* 10,000 covers a daily event with DTSTART ~27 years in the past.
|
|
||||||
*/
|
|
||||||
const MAX_RECURRENCE_ITERATIONS = 10_000
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a raw iCalendar string and extracts VEVENT components
|
* Parses a raw iCalendar string and extracts VEVENT components
|
||||||
* into CalDavEventData objects.
|
* into CalDavEventData objects.
|
||||||
@@ -113,23 +106,11 @@ export function parseICalEvents(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expand recurring event occurrences within the time range.
|
// Expand recurring event occurrences within the time range
|
||||||
// The iterator must start from DTSTART (not rangeStart) because
|
|
||||||
// ical.js needs to walk the recurrence rule grid from the original
|
|
||||||
// anchor. We cap iterations to avoid runaway expansion on
|
|
||||||
// pathological rules.
|
|
||||||
const iter = masterEvent.iterator()
|
const iter = masterEvent.iterator()
|
||||||
let next: InstanceType<typeof ICAL.Time> | null = iter.next()
|
let next: InstanceType<typeof ICAL.Time> | null = iter.next()
|
||||||
let iterations = 0
|
|
||||||
|
|
||||||
while (next) {
|
while (next) {
|
||||||
if (++iterations > MAX_RECURRENCE_ITERATIONS) {
|
|
||||||
console.warn(
|
|
||||||
`[aris.caldav] Recurrence expansion for "${masterEvent.uid}" hit iteration limit (${MAX_RECURRENCE_ITERATIONS}), stopping`,
|
|
||||||
)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop once we're past the range end
|
// Stop once we're past the range end
|
||||||
if (next.compare(rangeEnd) >= 0) break
|
if (next.compare(rangeEnd) >= 0) break
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user