Merge pull request #1857 from Silvertree2010/fix/h2736-iso-date-parser-accepts-any-char

Reject ISO timestamps without ':' between hour and minute
This commit is contained in:
aiongg authored and GitHub committed 2026-11-03 12:58:13 -05:00
commit ee5ea72aea
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