Skip to content

Commit 5a6b2b4

Browse files
pitdickerdjc
authored andcommitted
Fix arbitrary string slicing in parse_rfc3339_relaxed
1 parent e39346e commit 5a6b2b4

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/datetime/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ fn test_datetime_from_str() {
804804
.unwrap())
805805
);
806806
assert!("2015-2-18T23:16:9.15".parse::<DateTime<Utc>>().is_err());
807+
assert!("2015-02-18T23:16:9.15øøø".parse::<DateTime<Utc>>().is_err());
807808

808809
// no test for `DateTime<Local>`, we cannot verify that much.
809810
}

src/format/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn parse_rfc3339_relaxed<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseResult
586586
Ok(_) => return Err(NOT_ENOUGH),
587587
};
588588
s = s.trim_start();
589-
let (s, offset) = if s.len() >= 3 && "UTC".eq_ignore_ascii_case(&s[..3]) {
589+
let (s, offset) = if s.len() >= 3 && "UTC".as_bytes().eq_ignore_ascii_case(&s.as_bytes()[..3]) {
590590
(&s[3..], 0)
591591
} else {
592592
scan::timezone_offset(s, scan::colon_or_space, true, false, true)?

0 commit comments

Comments
 (0)