Skip to content

Commit

Permalink
Use the same check for T as in parse_rfc3339
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Jun 11, 2023
1 parent 34d8104 commit c1e1eb9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/format/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,14 @@ fn parse_rfc3339_relaxed<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseResult
Err((_s, e)) => return Err(e),
Ok(_) => return Err(NOT_ENOUGH),
};
if !(s.starts_with('T') || s.starts_with(' ')) {
return Err(INVALID);
}
s = match parse_internal(parsed, &s[1..], TIME_ITEMS.iter()) {

s = match s.as_bytes().first() {
Some(&b't' | &b'T' | &b' ') => &s[1..],
Some(_) => return Err(INVALID),
None => return Err(TOO_SHORT),
};

s = match parse_internal(parsed, s, TIME_ITEMS.iter()) {
Err((remainder, e)) if e.0 == ParseErrorKind::TooLong => remainder,
Err((_s, e)) => return Err(e),
Ok(_) => return Err(NOT_ENOUGH),
Expand Down

0 comments on commit c1e1eb9

Please sign in to comment.