Dates: four-digit years from 1900 to 2100
CI / secret scan (push) Successful in 4s
CI / fmt, clippy, tests (push) Successful in 20s

Chromium's date input lets the year part take six digits when the input
has no max, so typing 2026 and then 11 for the month gave 202611-12-05
(reported on the live app). Every date input now carries
min="1900-01-01" and max="2100-12-31", so the year part stops at four
digits and moves on to the month. Checked in Edge: typing 20261112 gives
2026-11-12, where it left the field empty before.

The server checks the same years for every date field
(dates::parse_form_date). Person, passport and address dates were only
parsed, so a two-digit year such as 0026-11-12 would have been saved;
stay records had the range already. A six-digit year never parsed, so no
such date can be in the database.

Tests: the parser's cases; the person, passport and arrival forms refuse
both years and save nothing; every date input on every page carries the
limits (pages.rs).
This commit is contained in:
grabowski committed 2026-11-17 21:15:14 +07:00
1 parent 38070ee135
commit d543c929e9
6 files changed
+147 -10

No files matched your search

+6 -4
View File
@@ -280,11 +280,13 @@ fn optional_date(value: &str, field: &str, e: &mut Errors) -> Option<NaiveDate>
if value.is_empty() {
return None;
}
let d = dates::parse_date(value);
if d.is_none() {
err(e, field, "Enter a date (year-month-day).");
match dates::parse_form_date(value) {
Ok(d) => Some(d),
Err(msg) => {
err(e, field, msg);
None
}
}
d
}
pub async fn get_person(db: &PgPool, id: i64) -> Result<Option<Person>> {