mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-04 18:22:26 +00:00
Fixed extraction of time-range filter from request when processing
expand property
This commit is contained in:
parent
3a6c72e93a
commit
2c4cd32132
2 changed files with 21 additions and 24 deletions
|
@ -233,22 +233,17 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
||||||
for filter_ in filters:
|
for filter_ in filters:
|
||||||
# extract time-range filter for processing after main filters
|
# extract time-range filter for processing after main filters
|
||||||
# for expand request
|
# for expand request
|
||||||
time_range_element = filter_.find(".//" + xmlutils.make_clark("C:time-range"))
|
filter_copy = copy.deepcopy(filter_)
|
||||||
|
|
||||||
if expand is None or time_range_element is None:
|
if expand is not None:
|
||||||
main_filters.append(filter_)
|
for comp_filter in filter_copy.findall(".//" + xmlutils.make_clark("C:comp-filter")):
|
||||||
|
if comp_filter.get("name", "").upper() == "VCALENDAR":
|
||||||
|
continue
|
||||||
|
time_range_element = comp_filter.find(xmlutils.make_clark("C:time-range"))
|
||||||
|
if time_range_element is not None:
|
||||||
|
comp_filter.remove(time_range_element)
|
||||||
|
|
||||||
# Extract requested component types from filters
|
main_filters.append(filter_copy)
|
||||||
requested_components = set()
|
|
||||||
has_vcalendar_filter = False
|
|
||||||
for filter_ in filters:
|
|
||||||
for comp_filter in filter_.findall(".//" + xmlutils.make_clark("C:comp-filter")):
|
|
||||||
component_name = comp_filter.get("name", "").upper()
|
|
||||||
if component_name:
|
|
||||||
if component_name == "VCALENDAR":
|
|
||||||
has_vcalendar_filter = True
|
|
||||||
else:
|
|
||||||
requested_components.add(component_name)
|
|
||||||
|
|
||||||
# Retrieve everything required for finishing the request.
|
# Retrieve everything required for finishing the request.
|
||||||
retrieved_items = list(retrieve_items(
|
retrieved_items = list(retrieve_items(
|
||||||
|
@ -275,13 +270,6 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
||||||
raise RuntimeError("Failed to filter item %r from %r: %s" %
|
raise RuntimeError("Failed to filter item %r from %r: %s" %
|
||||||
(item.href, collection.path, e)) from e
|
(item.href, collection.path, e)) from e
|
||||||
|
|
||||||
# Skip items that don't match requested component types, unless VCALENDAR filter allows all components
|
|
||||||
if requested_components and not has_vcalendar_filter:
|
|
||||||
if item.component_name not in requested_components:
|
|
||||||
logger.debug("Skipping component %r (type: %s) as it doesn't match requested components %s",
|
|
||||||
item.href, item.component_name, requested_components)
|
|
||||||
continue
|
|
||||||
|
|
||||||
found_props = []
|
found_props = []
|
||||||
not_found_props = []
|
not_found_props = []
|
||||||
|
|
||||||
|
@ -366,6 +354,8 @@ def _expand(
|
||||||
) -> Tuple[ET.Element, int]:
|
) -> Tuple[ET.Element, int]:
|
||||||
vevent_component: vobject.base.Component = copy.copy(item.vobject_item)
|
vevent_component: vobject.base.Component = copy.copy(item.vobject_item)
|
||||||
logger.info("Expanding event %s", item.href)
|
logger.info("Expanding event %s", item.href)
|
||||||
|
logger.debug(f"Expand range: {start} to {end}")
|
||||||
|
logger.debug(f"Time range: {time_range_start} to {time_range_end}")
|
||||||
|
|
||||||
# Split the vevents included in the component into one that contains the
|
# Split the vevents included in the component into one that contains the
|
||||||
# recurrence information and others that contain a recurrence id to
|
# recurrence information and others that contain a recurrence id to
|
||||||
|
|
|
@ -376,14 +376,21 @@ permissions: RrWw""")
|
||||||
self.put("/test/calendar.ics", get_file_content("event_daily_rrule.ics"))
|
self.put("/test/calendar.ics", get_file_content("event_daily_rrule.ics"))
|
||||||
self.put("/test/todo.ics", get_file_content("todo1.ics"))
|
self.put("/test/todo.ics", get_file_content("todo1.ics"))
|
||||||
|
|
||||||
request = """
|
start = "20060101T000000Z"
|
||||||
|
end = "20060104T000000Z"
|
||||||
|
|
||||||
|
request = f"""
|
||||||
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
|
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
<D:prop>
|
<D:prop>
|
||||||
<C:calendar-data/>
|
<C:calendar-data>
|
||||||
|
<C:expand start="{start}" end="{end}"/>
|
||||||
|
</C:calendar-data>
|
||||||
</D:prop>
|
</D:prop>
|
||||||
<C:filter>
|
<C:filter>
|
||||||
<C:comp-filter name="VCALENDAR">
|
<C:comp-filter name="VCALENDAR">
|
||||||
<C:comp-filter name="VEVENT"/>
|
<C:comp-filter name="VEVENT">
|
||||||
|
<C:time-range start="{start}" end="{end}"/>
|
||||||
|
</C:comp-filter>
|
||||||
</C:comp-filter>
|
</C:comp-filter>
|
||||||
</C:filter>
|
</C:filter>
|
||||||
</C:calendar-query>
|
</C:calendar-query>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue