From 8cc0d3ac0f8e7030ff40958ffe63f76087c0c00e Mon Sep 17 00:00:00 2001 From: Fredrik Meringdal Date: Mon, 15 Feb 2021 16:12:04 +0100 Subject: infinite loop bug fix --- src/rrulestr.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/rrulestr.rs') diff --git a/src/rrulestr.rs b/src/rrulestr.rs index 62d1faa..bf616ba 100644 --- a/src/rrulestr.rs +++ b/src/rrulestr.rs @@ -748,4 +748,18 @@ mod test { assert_eq!(occurences.len(), 7); assert!(Utc::now().timestamp() - occurences[0].timestamp() < 2); } + + #[test] + fn avoids_infinite_loop() { + let rrule = + "DTSTART:20200427T090000\nFREQ=WEEKLY;UNTIL=20200506T035959Z;BYDAY=FR,MO,TH,TU,WE" + .parse::() + .unwrap(); + let instances: Vec<_> = rrule + .into_iter() + .skip_while(|d| *d < Local::now()) + .take(2) + .collect(); + assert_eq!(instances.len(), 0); + } } -- cgit v1.2.3