fix(docs): build ERD search results via DOM, not innerHTML#546
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Final code-review follow-up (#545). The ER-diagram viewer's search dropdown was the one runtime
innerHTMLsink: it concatenated each tableidinto<div data-id="…">…</div>. Safe for currentsnake_casenames, 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 onmatchBox.childrenanddata-id, so behavior is unchanged. Output now has zeroinnerHTML.Verification
schema-erd.html; embedded viewer JSnode --checkcleanrender-schema-diagram.mjsnode --checkcleanOn the other deferred item (generated-date churn)
Not fixed because it's moot:
schema-erd.htmlcarries no date stamp (verified), so it doesn't churn. Onlyschema.md/schema.dbmlembed 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