Fix: time-range filter on VTODO with DTSTART/DUE and CREATED/COMPLETED
visit_time_ranges() reuses a single "original_duration" variable for two unrelated purposes: the DTSTART->DUE span and the CREATED->COMPLETED span. When a VTODO carries all four properties (a completed task, which most clients write with CREATED and COMPLETED), the second assignment clobbers the first, and the DTSTART/DUE branch of the rfc4791-9.9 table then reconstructs DUE as DTSTART + (COMPLETED - CREATED). The elif chain already implements the RFC table correctly (DTSTART/DUE take precedence over CREATED/COMPLETED), so the CREATED/COMPLETED value is never wanted there. Keep it in its own variable. Effect: such a VTODO is filtered against a bogus interval, both in calendar-query REPORT and in item.find_time_range() (the enclosing range cached for the storage prefilter), so completed tasks go missing from - or wrongly appear in - client results. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -442,7 +442,10 @@ def visit_time_ranges(vobject_item: vobject.base.Component, child_name: str,
|
||||
completed = date_to_datetime(completed.value)
|
||||
if created is not None:
|
||||
created = date_to_datetime(created.value)
|
||||
original_duration = (completed - created).total_seconds()
|
||||
# NOTE: kept separate from "original_duration", otherwise a
|
||||
# VTODO with DTSTART+DUE and also CREATED+COMPLETED would
|
||||
# lose its DTSTART->DUE duration (see line 2 below)
|
||||
completed_duration = (completed - created).total_seconds()
|
||||
elif created is not None:
|
||||
created = date_to_datetime(created.value)
|
||||
|
||||
@@ -500,7 +503,7 @@ def visit_time_ranges(vobject_item: vobject.base.Component, child_name: str,
|
||||
elif completed is not None and created is not None:
|
||||
# Line 5
|
||||
completed = reference_date + timedelta(
|
||||
seconds=original_duration)
|
||||
seconds=completed_duration)
|
||||
if (range_fn(reference_date - SECOND,
|
||||
reference_date + SECOND,
|
||||
is_recurrence) or
|
||||
|
||||
Reference in New Issue
Block a user