Skip to content

fix(docs): build ERD search results via DOM, not innerHTML#546

Merged
aaronsb merged 1 commit into
mainfrom
fix/erd-search-dropdown-dom
Jul 2, 2026
Merged

fix(docs): build ERD search results via DOM, not innerHTML#546
aaronsb merged 1 commit into
mainfrom
fix/erd-search-dropdown-dom

Conversation

@aaronsb

@aaronsb aaronsb commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Why

Final code-review follow-up (#545). The ER-diagram viewer's search dropdown was the one runtime innerHTML sink: it concatenated each table id into <div data-id="…">…</div>. Safe for current snake_case names, but an identifier with unusual characters would break the row or inject markup.

Fix

Build each row with createElement + setAttribute("data-id", id) + textContent = id, so the id is treated as data, never parsed as markup. The keydown/click handlers already operate on matchBox.children and data-id, so behavior is unchanged. Output now has zero innerHTML.

Verification

  • Regenerated schema-erd.html; embedded viewer JS node --check clean
  • render-schema-diagram.mjs node --check clean

On the other deferred item (generated-date churn)

Not fixed because it's moot: schema-erd.html carries no date stamp (verified), so it doesn't churn. Only schema.md/schema.dbml embed a date, matching the existing convention for every generated reference doc — a separate cross-cutting decision, out of scope here.

https://claude.ai/code/session_017Her5fGimBvtzYD4q9tNnf

The schema-diagram viewer's table-search dropdown built its rows by
concatenating each table id into an HTML string and assigning innerHTML. Safe
for today's snake_case identifiers, but a table name with unusual characters
would break the row or inject markup. Build the rows with
createElement/setAttribute/textContent so the id is never parsed as markup.

Last code-review follow-up; removes the viewer's only runtime innerHTML sink.

Claude-Session: https://claude.ai/code/session_017Her5fGimBvtzYD4q9tNnf
@aaronsb aaronsb merged commit b6ebe03 into main Jul 2, 2026
6 checks passed
@aaronsb aaronsb deleted the fix/erd-search-dropdown-dom branch July 2, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant