From 93e2a91618f4cac218a2ce0df9788d357f1cd7d8 Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Tue, 18 Apr 2023 08:24:35 +0200 Subject: [PATCH] Add test for string slicing panic from issue 1010 --- src/format/parse.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/format/parse.rs b/src/format/parse.rs index 0f50b4a4be..e894f710b9 100644 --- a/src/format/parse.rs +++ b/src/format/parse.rs @@ -997,3 +997,11 @@ fn test_rfc3339() { } } } + +#[cfg(test)] +#[test] +fn test_issue_1010() { + let dt = crate::NaiveDateTime::parse_from_str("\u{c}SUN\u{e}\u{3000}\0m@J\u{3000}\0\u{3000}\0m\u{c}!\u{c}\u{b}\u{c}\u{c}\u{c}\u{c}%A\u{c}\u{b}\0SU\u{c}\u{c}", + "\u{c}\u{c}%A\u{c}\u{b}\0SUN\u{c}\u{c}\u{c}SUNN\u{c}\u{c}\u{c}SUN\u{c}\u{c}!\u{c}\u{b}\u{c}\u{c}\u{c}\u{c}%A\u{c}\u{b}%a"); + assert_eq!(dt, Err(ParseError(ParseErrorKind::Invalid))); +}