From a859fe38b1044c576f042254a0f9677054b417a0 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 23 May 2024 08:55:53 +0200 Subject: test calendar-query vevent filtering --- aero-dav/src/caldecoder.rs | 11 +++++++++++ aero-dav/src/xml.rs | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'aero-dav') diff --git a/aero-dav/src/caldecoder.rs b/aero-dav/src/caldecoder.rs index 02991c2..6bc911f 100644 --- a/aero-dav/src/caldecoder.rs +++ b/aero-dav/src/caldecoder.rs @@ -973,6 +973,17 @@ mod tests { rdr.find().await.unwrap() } + #[tokio::test] + async fn simple_comp_filter() { + let expected = CompFilter { + name: Component::VEvent, + additional_rules: None, + }; + let src = r#""#; + let got = deserialize::(src).await; + assert_eq!(got, expected); + } + #[tokio::test] async fn basic_mkcalendar() { let expected = MkCalendar(dav::Set(dav::PropValue(vec![dav::Property::DisplayName( diff --git a/aero-dav/src/xml.rs b/aero-dav/src/xml.rs index c89f531..e59f136 100644 --- a/aero-dav/src/xml.rs +++ b/aero-dav/src/xml.rs @@ -229,7 +229,10 @@ impl Reader { } pub async fn maybe_find>(&mut self) -> Result, ParsingError> { - self.ensure_parent_has_child()?; + // We can't find anything inside a self-closed tag + if !self.parent_has_child() { + return Ok(None); + } loop { // Try parse @@ -238,6 +241,7 @@ impl Reader { otherwise => return otherwise.map(Some), } + // Skip or stop match self.peek() { Event::End(_) => return Ok(None), _ => self.skip().await?, -- cgit v1.2.3