Skip to content

Commit

Permalink
don't tolerate leading "+" in parse_two_digit_numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
mumbleskates committed Jul 7, 2024
1 parent 8dc3ce1 commit 2e43e02
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bilrost-types/src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ fn parse_two_digit_numeric(s: &str) -> Option<(u8, &str)> {
if s.len() < 2 {
return None;
}
if s.starts_with("+") {
return None;
}
let (digits, s) = s.split_at(2);
Some((digits.parse().ok()?, s))
}
Expand Down Expand Up @@ -798,6 +801,11 @@ mod tests {
// Leap year bug
check_timestamp("1900-01-10", Timestamp::date(1900, 1, 10));
check_timestamp("1900-01-10", Ok(Timestamp{seconds: -2208211200, nanos: 0}));
// Leading '+' in two-digit numbers
assert_eq!(
"19+1-+2-+3T+4:+5:+6Z".parse::<Timestamp>(),
Err(crate::TimestampError::ParseFailure),
)
}

#[test]
Expand Down

0 comments on commit 2e43e02

Please sign in to comment.