Title: id(web/editor): ordered_list parseDOM bare Number() lets NaN/fractional start through — pasted lists silently renumber from 1 on save · Issue #2005 · developing-today/code · GitHub
Open Graph Title: id(web/editor): ordered_list parseDOM bare Number() lets NaN/fractional start through — pasted lists silently renumber from 1 on save · Issue #2005 · developing-today/code
X Title: id(web/editor): ordered_list parseDOM bare Number() lets NaN/fractional start through — pasted lists silently renumber from 1 on save · Issue #2005 · developing-today/code
Description: Summary The web editor's ordered_list DOM parser (pkgs/id/web/src/editor.ts:100) reads the list start with a bare Number(el.getAttribute("start")). Non-numeric and fractional start values from pasted HTML therefore enter the ProseMirror ...
Open Graph Description: Summary The web editor's ordered_list DOM parser (pkgs/id/web/src/editor.ts:100) reads the list start with a bare Number(el.getAttribute("start")). Non-numeric and fractional start values from past...
X Description: Summary The web editor's ordered_list DOM parser (pkgs/id/web/src/editor.ts:100) reads the list start with a bare Number(el.getAttribute("start")). Non-numeric and fractional start va...
Opengraph URL: https://github.com/developing-today/code/issues/2005
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web/editor): ordered_list parseDOM bare Number() lets NaN/fractional start through — pasted lists silently renumber from 1 on save","articleBody":"## Summary\n\nThe web editor's `ordered_list` DOM parser (`pkgs/id/web/src/editor.ts:100`) reads the list start with a bare `Number(el.getAttribute(\"start\"))`. Non-numeric and fractional `start` values from pasted HTML therefore enter the ProseMirror node unchecked:\n\n- `start=\"abc\"` → `order = NaN`. The schema's only guard is `validate: \"number\"` (`editor.ts:115`), and ProseMirror's string validator checks only `typeof value` (`prosemirror-model` `validateType`: `typeof NaN === \"number\"`), so NaN passes.\n- `editor.ts:105` `toDOM` then renders any `order !== 1` as `start: NaN` — an invalid HTML attribute.\n- On save, the node JSON carries `order: null` (`JSON.stringify(NaN)`), and the Rust markdown codec reads it as `json[\"attrs\"][\"order\"].as_u64().unwrap_or(1)` (`pkgs/id/src/web/markdown.rs:1844-1845`) — the list is **silently renumbered from 1**.\n- `start=\"2.5\"` → `order = 2.5` (same validate pass, `start=\"2.5\"` rendered) → `as_u64` on a fractional JSON number is also `None` → silently renumbered from 1 on save.\n- `start=\"0x10\"` → reinterpreted as 16, `start=\"1e2\"` as 100 — forms an HTML `start` attribute never means (the sibling task-list parser at `editor.ts:196` correctly uses the `el.start` IDL property, which follows HTML's integer parsing rules).\n\nSo a pasted ordered list whose `start` is not a plain integer either displays with a bogus start attribute or loses its numbering entirely on the next save, with no signal at any step. The control case works end to end: `start=\"5\"` → order 5 → rendered 5 → saved 5.\n\n## Evidence (verified this run)\n\nLaptop probe (`~/git/fleet/probe-2026-10-28-laneB-olstart/`, node, main `6a284efd`) evaluating the verbatim `editor.ts:100` expression, the vendored `prosemirror-model` `validateType` semantics, the `editor.ts:105` `toDOM` branch, JSON round-trip, and the `markdown.rs:1845` `as_u64().unwrap_or(1)` read:\n\n```\nstart=\"5\" -> order=5 validate=ok toDOM start=5 json=5 rust_save_order=5\nstart=\"abc\" -> order=NaN validate=ok toDOM start=NaN json=null rust_save_order=1\nstart=\"2.5\" -> order=2.5 validate=ok toDOM start=2.5 json=2.5 rust_save_order=1\nstart=\"-3\" -> order=-3 validate=ok toDOM start=-3 json=-3 rust_save_order=1\nstart=\"0x10\" -> order=16 validate=ok toDOM start=16 json=16 rust_save_order=16\nstart=\"1e2\" -> order=100 validate=ok toDOM start=100 json=100 rust_save_order=100\n(no attr) -> order=1 validate=ok toDOM (no attr) json=1 rust_save_order=1\n```\n\nSource lines: `editor.ts:100` (bare `Number()`), `editor.ts:111-116` (`order: { default: 1, validate: \"number\" }`), `editor.ts:105` (toDOM), `markdown.rs:1844-1845` (`as_u64().unwrap_or(1)`). The image attrs at `editor.ts:145-146` use the same bare `Number()` for `width`/`height` (`\"100px\"` → NaN, silently dropped by the falsy check in `toDOM`) — same fix shape, worth covering in the same change if triage agrees.\n\nThis is the parser-strictness class the web code has been fixing one site at a time: go-to-line strict validation (#712), world seed digits-only (#832), identity refresh finite check (#847). This `parseDOM` site is unguarded.\n\n## Why it matters\n\nPaste is how existing documents arrive in the editor. A list pasted from a web page or another editor with an unusual `start` keeps its numbering on screen (or shows `NaN`) and then silently renumbers from 1 when saved — the saved markdown no longer says what the user saw and confirmed. Silent reinterpretation (`0x10` → 16) is the same class of harm in the other direction.\n\n## Acceptance criteria\n\n- [ ] The `ordered_list` `parseDOM` getAttrs produces only a valid list start: a finite integer the save codec can represent (non-negative safe integer), or falls back to 1 — never NaN, a fraction, or a hex/scientific reinterpretation. Using `el.start` (as the task-list parser at `editor.ts:196` does) plus a range/integer check is an acceptable shape; triage pins the exact fallback for negative starts, which markdown cannot represent.\n- [ ] A pasted `\u003col start=\"5\">` still round-trips: order 5 in the node, `start=\"5\"` rendered, 5 in the saved markdown.\n- [ ] Tests in `editor.test.ts` (or the schema's test home) cover at least: `start=\"abc\"`, `start=\"2.5\"`, `start=\"0x10\"`, and the `start=\"5\"` control.\n- [ ] If triage includes them, the image `width`/`height` attrs at `editor.ts:145-146` get the same treatment (`\"100px\"`/non-numeric → null, plain integer preserved).\n- [ ] Existing web unit tests pass.\n\nFound by new-issue-creator lane B, 2026-10-28 run. Dedup: `gh search issues` for \"ordered list start\", \"parseDOM start\", \"ol start NaN editor\" (open + closed) returned no matching issue. Related but distinct closed issues: #1469 (lists lose their `tight` flag — a different attr) and #997 (ordered *task* lists rewritten as bullet lists on save — the `contains-task-list` branch at `editor.ts:196`, not the plain `ordered_list` getAttrs at `editor.ts:100` covered here).\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T23:52:25Z","url":"https://github.com/developing-today/code/issues/2005"}
| 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:96e86ced-2e4b-ed24-415b-39a5f6780f79 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED74:804E:C8DFFC:103D536:6B06407B |
| html-safe-nonce | 5d79083de0a0d9eca568141a0dec525fd44055867756ccc892ea803b80994ea9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDc0OjgwNEU6QzhERkZDOjEwM0Q1MzY6NkIwNjQwN0IiLCJ2aXNpdG9yX2lkIjoiMTU2MTE5NTc2MjE5MTA3NDUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3945e0e22c3eac4a48879e1d5d287c203ef77f60f9cb3e796325fb3d522be177 |
| hovercard-subject-tag | issue:6089705926 |
| 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/2005/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5e9f1167a838270b5fd08b9f810772d81b9f26d0908b74bf95c0c1604d3895db/developing-today/code/issues/2005 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5e9f1167a838270b5fd08b9f810772d81b9f26d0908b74bf95c0c1604d3895db/developing-today/code/issues/2005 |
| og:image:alt | Summary The web editor's ordered_list DOM parser (pkgs/id/web/src/editor.ts:100) reads the list start with a bare Number(el.getAttribute("start")). Non-numeric and fractional start values from past... |
| 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 | 1bff4f6bfaa96dc9c42cacf315424c24ebb548b06142ced5e3aaccb2a42dd652 |
| 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 | ac613d3698d3d8565651455086e1f74da07bf277 |
| 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