Skip to content

id(web): spaced-destination placeholder can collide with document text — global replace on save rewrites the document's own words (PR #1022) #1348

Open

Description

@dezren39

Finding

PR #1022 (merged, merge commit 76672b9) preserves spaced link/image destinations by swapping each one for a deterministic placeholder before rendering and restoring it afterwards with a global string replace over the whole rendered document:

pkgs/id/src/web/markdown.rs (current main):

  • :1100-1103 — placeholder is format!("idweb-spaced-destination-{}-placeholder", substitutions.len()), derived only from the substitution index; nothing checks whether that token already occurs in the document.
  • :1070-1072 — restoration is output = output.replace(&placeholder, &format!("<{raw}>")), which replaces EVERY occurrence in the rendered markdown, not just the destination the renderer emitted.

Why it matters

If the document's own text (or a code block, or another non-spaced destination) literally contains idweb-spaced-destination-0-placeholder and the document also has a spaced link/image destination, the save direction rewrites the document's own text into <the spaced destination> — silent content corruption on save, in the same codec family as the %20 mutation #1022 set out to fix. The token is fixed and guessable, so the collision does not require exotic input for anyone documenting this codec. The tests added by #1022 cover destinations, titles, and editor hrefs, but not a document that already contains the placeholder token. Verified still present on current main (2026-10-27).

Evidence

Acceptance criteria

  • Placeholder tokens are chosen so they cannot collide with content already in the document (e.g. scan the AST's text/literal/url content and keep extending/randomizing the token until it is absent), OR restoration is scoped to the rendered destination positions instead of a global replace.
  • Regression test: a document containing the literal current token text plus a spaced link destination round-trips with the literal text unchanged and the destination in <...> angle form.
  • Existing id(web): link/image destinations with a space are silently rewritten to %20 on save — angle-bracket form lost, relative file links break #1019 tests (spaced link, spaced image, title, editor href) still pass and round-trips remain fixpoints.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Oct 27, 2026
  2. developing-today commented on Oct 27, 2026

    @developing-today
    Contributor
  3. added
    priority/lowNice to have; do when convenient
    queue/queuedHas a queued task in the Supabase agent queue
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Oct 27, 2026
  4. dezren39 commented on Oct 27, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: pr-diff-review job
    • Session / ID: pr-diff-review cron run 2026-10-27T07:28:52Z
    • Found via: filed this run
    • Task: Triage this PR-diff-review finding against current main (queued as a repo-task/v1 triage packet)
    • Expectation: effort class s — verify the finding against current main, then scope the fix
    • Links: source PR and evidence in the issue body
  5. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  6. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: handed off

  7. 83 remaining items

  8. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    queue/claimedQueue worker lifecycle state
    on Nov 6, 2026
  9. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  10. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  11. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  12. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  13. dezren39 commented on Nov 6, 2026

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

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientqueue/parkedQueue task is parked (waiting on CI, time, or an event)source/pr-diff-reviewFiled by the pr-diff-review jobstatus/parkedDeliberately paused with a recorded resume conditiontask/triageQueue packet kind: verify, reproduce, and route this itemuser/reviewNeeds a user-look: Muse reviews first and handles what it canwork/assignedQueue worker lifecycle state

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions