Skip to content

id(web/editor): task_list parseDOM reads el.start unvalidated — the #2005 ordered_list fix does not cover ordered task lists; fractional/negative starts save as bullet lists, hex/scientific starts are reinterpreted #4100

Closed

Description

@dezren39

Problem

In the id web editor, the task_list node's parseDOM rule for <ol> reads the list start from the DOM's own el.start reflection instead of the validated parseOrderedListStart helper that #2005 / PR #4078 added for the sibling ordered_list rule in the same file — so ordered task lists still admit every start value that fix was created to reject:

  • pkgs/id/web/src/editor.ts:210-218 — both branches of the task_list <ol> rule return { order: el.start }. el.start is whatever the DOM implementation makes of the raw attribute; nothing checks it is a plain non-negative decimal integer.
  • pkgs/id/web/src/editor.ts:46-57,118 — parseOrderedListStart (plain \d+, safe-integer, fallback 1) is applied only to ordered_list. The task_list attrs (editor.ts:203) declare order: { default: null } with no validation.
  • pkgs/id/src/web/markdown.rs:4378 — on save, the codec reads task_list attrs.order via as_u64(): a negative or fractional order reads as None, and the list is rebuilt as a bullet task list (markdown.rs:4379-4390). A pasted ordered task list silently loses its ordering on save.
  • pkgs/id/web/src/editor.ts:220-227 — the task_list toDOM emits start="<order>" for any order ≠ 1, so a stored -3 or 2.5 round-trips into the rendered HTML verbatim until the save drops the ordering entirely.

Verified this run (2026-11-01, main ceba688a; laptop clone at 7a0da2fc, editor.ts md5 82283862fb30369b0bc9864a49c2568d identical on both)

Probe on the laptop (~/git/fleet/probe-2026-11-01-laneA-tasklist-start/, happy-dom — the DOM implementation of the repo's own test suite, pkgs/id/web/vitest.config.ts — reading el.start exactly as editor.ts:214/216 does, against parseOrderedListStart, the helper copied verbatim):

start attr task_list el.start → saves as ordered_list parseOrderedListStart
(absent) 1 → ordered from 1 1
5 / 0 / 42 5 / 0 / 42 → preserved 5 / 0 / 42
2.5 2.5 → bullet (as_u64 None) 1
-3 -3 → bullet (as_u64 None) 1
"" 0 → ordered from 0 1
0x10 16 → saved as 16 (reinterpreted) 1
1e3 1000 → saved as 1000 (reinterpreted) 1
9007199254740993 9007199254740992 → saved rounded 1

In a spec-compliant browser el.start is the IDL signed-long reflection, whose details differ (it truncates 2.5 to 2, parses 0x10 as 0, clamps huge values to 2147483647) — but it still bypasses the fallback-to-1 rule, still truncates instead of rejecting, and still admits negatives that the u64 codec cannot represent. Neither reflection is the validated read #2005 established.

Why it matters

This is the residual half of #2005 in the same schema: the plain ordered list was hardened, the ordered task list — which shares the <ol start> surface and the same u64 save codec — was not. Pasted web content is the realistic source (task lists copied from rendered HTML carry whatever start the source page had), and the failure shapes are the two #2005/#2010 classics: silent reinterpretation (0x10 → 16) and silent loss on save (negative/fractional → bullet list). Distinct from #2010 (image width/height Number() in the same file) — different node, different expression, different downstream failure.

Acceptance criteria

  • The task_list <ol> parseDOM rule derives order from parseOrderedListStart(el.getAttribute("start")) (or an equivalent validated read): only a plain non-negative decimal integer within safe range is preserved (0 included); malformed, fractional, negative, hex/scientific, empty, or unsafe values fall back to 1, exactly as ordered_list — in both branches (class-matched and checkbox-detected).
  • Tests mirroring the id(web/editor): ordered_list parseDOM bare Number() lets NaN/fractional start through — pasted lists silently renumber from 1 on save #2005 ordered_list start parsing block cover the task_list rule's getAttrs for the same value set (5, 0, 42 preserved; abc, 2.5, 0x10, 1e3, empty, -3, 9007199254740993 → 1; absent → 1).
  • The editor test suite passes (bun run test in pkgs/id/web or CI equivalent).

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    priority/lowNice to have; do when convenient
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    work/self-assignedAn agent grabbed this item directly, outside the queue
    effort/xsTrivial: expected under 30 minutes of work
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: self-assigned

  3. added a commit that references this issue on Nov 2, 2026
  4. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator job

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions