Reject ISO timestamps without ':' between hour and minute

Found while testing crates/doc/src/vars.rs:178 (parse_iso_date, `let (h, mi) = (tnum(0, 2)?, tnum(3, 5)?);`)

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
NetterSilverandClaude Haiku 5.5 committed 2026-10-26 04:43:37 +00:00
1 parent ed8aabd1dc
commit b35e31d963
1 file changed
+9
+9
View File
@@ -175,6 +175,9 @@ pub fn parse_iso_date(s: &str) -> Option<i64> {
let t = time.get(a..b)?;
t.bytes().all(|c| c.is_ascii_digit()).then(|| t.parse().ok()).flatten()
};
if time.get(2..3) != Some(":") {
return None;
}
let (h, mi) = (tnum(0, 2)?, tnum(3, 5)?);
let mut i = 5;
let mut sec = 0;
@@ -290,6 +293,12 @@ impl Document {
mod tests {
use super::*;
#[test]
fn iso_date_requires_colon_separator() {
assert_eq!(parse_iso_date("2019-12-16T09:48:00Z"), Some(1_576_489_680));
assert_eq!(parse_iso_date("2019-12-16T09x48:00Z"), None);
}
#[test]
fn dates() {
// 2026-10-01 14:05 UTC