Title: id(web): parse_iso_timestamp accepts out-of-range dates — month 13, day 0/32, Feb 30, hour 25 and pre-1970 years all return plausible-but-wrong timestamps · Issue #756 · developing-today/code · GitHub
Open Graph Title: id(web): parse_iso_timestamp accepts out-of-range dates — month 13, day 0/32, Feb 30, hour 25 and pre-1970 years all return plausible-but-wrong timestamps · Issue #756 · developing-today/code
X Title: id(web): parse_iso_timestamp accepts out-of-range dates — month 13, day 0/32, Feb 30, hour 25 and pre-1970 years all return plausible-but-wrong timestamps · Issue #756 · developing-today/code
Description: Problem parse_iso_timestamp in pkgs/id/src/web/routes.rs:148-201 — the parser behind classify_tag (routes.rs:125-141) for auto-
Open Graph Description: Problem parse_iso_timestamp in pkgs/id/src/web/routes.rs:148-201 — the parser behind classify_tag (routes.rs:125-141) for auto-
X Description: Problem parse_iso_timestamp in pkgs/id/src/web/routes.rs:148-201 — the parser behind classify_tag (routes.rs:125-141) for auto-<ISO date> backup tag names — performs no range validation on an...
Opengraph URL: https://github.com/developing-today/code/issues/756
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web): parse_iso_timestamp accepts out-of-range dates — month 13, day 0/32, Feb 30, hour 25 and pre-1970 years all return plausible-but-wrong timestamps","articleBody":"## Problem\n\n`parse_iso_timestamp` in `pkgs/id/src/web/routes.rs:148-201` — the parser behind `classify_tag` (`routes.rs:125-141`) for `auto-\u003cISO date>` backup tag names — performs **no range validation** on any component. Out-of-range values are silently rolled over into a different, plausible timestamp instead of returning `None`, and a pre-1970 year is clamped to the epoch. The resulting `FileInfo.timestamp` (`routes.rs:714`, second pass of the file-list builder) therefore shows/sorts an auto-backup under a date its name does not contain.\n\n## Evidence (verified this run)\n\nThe function was extracted verbatim from current main and run standalone (`rustc -O`, unmodified logic). The valid control matches the known epoch exactly:\n\n| Input | Result | Correct behaviour |\n|---|---|---|\n| `2026-03-12T06:42:30Z` | `Some(1773297750)` | ✅ matches reference epoch |\n| `2026-13-01T00:00:00Z` | `Some(1798761600)` (= 2027-01-01) | month 13 rolls into next year |\n| `2026-00-01T00:00:00Z` | `Some(1767225600)` (= 2026-01-01) | month 0 silently becomes January |\n| `2026-03-00T00:00:00Z` | `Some(1772323200)` | **identical to `2026-03-01`** — day 0 == day 1 |\n| `2026-03-32T00:00:00Z` | `Some(1775001600)` (= 2026-04-01) | day 32 rolls into April |\n| `2026-02-30T00:00:00Z` | `Some(1772409600)` (= 2026-03-02) | Feb 30 rolls into March |\n| `2026-03-12T25:00:00Z` | `Some(1773363600)` | hour 25 rolls into the next day |\n| `2026-03-12T00:60:00Z` / `T00:00:60Z` | `Some(...)` | minute/second 60 roll over |\n| `1969-01-01T00:00:00Z` | `Some(0)` | **identical to the epoch** — the `1970..year` loop never runs and the date collapses to 1970-01-01 |\n\nContributing code:\n\n- `routes.rs:165-168` — components are collected with `filter_map(|p| p.parse().ok())`, so only count is checked, never range.\n- `routes.rs:182` — the month loop is capped only by the `month_days` array length, so month 13 accumulates a full year.\n- `routes.rs:190` — `day.saturating_sub(1)` makes day 0 indistinguishable from day 1.\n- `routes.rs:192` — `hour * 3600 + min * 60 + sec` accepts any hour/minute/second.\n\nRelated robustness note (same function): the days calculation loops `for y in 1970..year` with no upper bound, so a tag named e.g. `auto-999999999-01-01T00:00:00Z` makes the file-list handler iterate ~10⁹ times for that one name. A year-range check fixes this too.\n\nExisting tests (`routes.rs:2236-2259`) cover only a valid date, garbage strings, and the epoch — no out-of-range component is tested.\n\n## Why it matters\n\nAuto-backup names are generated (`auto-2026-03-12T06:42:30.015Z`), but tag names are user/peer-controlled data in a p2p store: a malformed or adversarial `auto-…` name is displayed and ordered as if it were a real backup from a different date (a \"Feb 30\" backup sorting as Mar 2, a 1969 backup claiming the epoch), and an absurd year can stall the file list. A parser that cannot represent a date should say so (`None`, which `classify_tag` already handles) rather than invent one.\n\n## Acceptance criteria\n\n- [ ] `parse_iso_timestamp` returns `None` for: month outside 1–12, day 0 or greater than the days in that month for that year (incl. Feb 29 on a non-leap year, Feb 30 always), hour > 23, minute > 59, second > 59.\n- [ ] Years before 1970 return `None` (the `u64` result cannot represent them) instead of `Some(0)`.\n- [ ] The year loop is bounded (the range check above suffices) — no per-year iteration for absurd years.\n- [ ] Valid inputs are unchanged: `2026-03-12T06:42:30.015Z` → `1773297750`, `1970-01-01T00:00:00Z` → `0`, Feb 29 on a leap year (e.g. 2024-02-29) parses correctly.\n- [ ] New unit tests next to the existing ones at `routes.rs:2236+` cover each rejected class and the leap-day cases; existing `test_classify_tag_*` / `test_parse_iso_timestamp_*` tests still pass.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-24T12:18:21Z","url":"https://github.com/developing-today/code/issues/756"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:656ab712-f0bd-9d9a-177e-d7e00e2d7e90 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B596:EC78C:8BD267:BA8761:6B06368A |
| html-safe-nonce | 603a9ec3fcc9029a8df3292d4800fa151c912a74112079d2c0de4cfa50b4dce6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTk2OkVDNzhDOjhCRDI2NzpCQTg3NjE6NkIwNjM2OEEiLCJ2aXNpdG9yX2lkIjoiMzI1NzY0NDcwODA5MTc5Nzg3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 09a0892948ad4a397175091580bc4104dd2abff650c43309e82deb975c40d2a1 |
| hovercard-subject-tag | issue:6012843215 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/756/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1bfd77dc7e8588472d0acdd643883486515f179db7d06325f69a180f8aa2ed41/developing-today/code/issues/756 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1bfd77dc7e8588472d0acdd643883486515f179db7d06325f69a180f8aa2ed41/developing-today/code/issues/756 |
| og:image:alt | Problem parse_iso_timestamp in pkgs/id/src/web/routes.rs:148-201 — the parser behind classify_tag (routes.rs:125-141) for auto- |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | c3584c853cd39700ecff6e2cf8364295ffdb5313e571046c41cd2479270f7df0 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9eb3bb1597d09170a5f282cd38ae376dee1a5ec1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width