Skip to content

Commit

Permalink
Fix arbitrary string slicing in parse_rfc3339_relaxed
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Sep 4, 2023
1 parent e39346e commit 0e14716
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/datetime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ fn test_datetime_from_str() {
.unwrap())
);
assert!("2015-2-18T23:16:9.15".parse::<DateTime<Utc>>().is_err());
assert!("2015-02-18T23:16:9.15øøø".parse::<DateTime<Utc>>().is_err());

// no test for `DateTime<Local>`, we cannot verify that much.
}
Expand Down
2 changes: 1 addition & 1 deletion src/format/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ fn parse_rfc3339_relaxed<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseResult
Ok(_) => return Err(NOT_ENOUGH),
};
s = s.trim_start();
let (s, offset) = if s.len() >= 3 && "UTC".eq_ignore_ascii_case(&s[..3]) {
let (s, offset) = if s.len() >= 3 && "UTC".as_bytes().eq_ignore_ascii_case(&s.as_bytes()[..3]) {
(&s[3..], 0)
} else {
scan::timezone_offset(s, scan::colon_or_space, true, false, true)?
Expand Down

0 comments on commit 0e14716

Please sign in to comment.