fix: append parsed nodes when loading initial HTML into the Lexical editor

EditorShell's ingest called $generateNodesFromDOM but discarded the
returned nodes, so stored content never appeared in the WYSIWYG editor
in edit mode (the E2E edit test only checked title/points and missed it).
The parsed nodes are now appended to the root (kept empty-paragraph
default when nothing parses).

Hardening tests added while auditing the M6 test checklist:
- E2E: edit view asserts the stored body renders in the editor; new
  hostile-HTML test loads <script> tags, onerror/onload handlers and
  javascript: links through the real editor and asserts none survive
  into the contenteditable and nothing executes.
- E2E/unit: create button is disabled while the request is in flight.
- Backend: SQL metacharacters in the search term behave as literal
  text and leave the table intact.

Milestone doc updated: QA checklist items now cite their tests, plus a
QA-findings note for the ingest bug.
This commit is contained in:
Daniel Samson committed 2026-10-30 21:58:23 +00:00
1 parent b440809548
commit e62fad4a10
5 files changed
+104 -3

No files matched your search

+14 -2
View File
@@ -302,6 +302,18 @@ Implementation notes (deviations from the prompt sketch, matching project conven
- Rate limiting is implemented in-memory (1000 req/60s per admin; 429 on breach)
rather than a placeholder.
QA findings from M6 (all fixed):
- The editor's `initialHtml` ingest called `$generateNodesFromDOM` but
discarded the returned nodes, so stored content never appeared in the
WYSIWYG editor in edit mode. Fixed by appending the parsed nodes to the
root; covered by the E2E edit + hostile-HTML tests.
- XSS: the E2E hostile-HTML test loads `<script>`, `onerror`/`onload`
handlers and `javascript:` links through the real editor and asserts
none of it survives into the contenteditable (nothing executes).
- SQL injection: the backend search test feeds `1=1' OR '1'='1` as a
search term and asserts literal-substring behaviour plus table integrity.
## Technical Details
### Database Schema Update
@@ -574,8 +586,8 @@ export function DeleteConfirmation({ itemId, itemName, onConfirm, onCancel }: De
- [x] Direct URL access to /api/v1/admin/items → 403 for non-admins
- [x] Token tampering doesn't bypass admin check (JWT signature validation)
- [x] Rate limiting active (in-memory, 1000 req/60s per admin → 429)
- [x] Input sanitization prevents SQL injection (SQLAlchemy parameterized queries)
- [x] XSS prevention in Lexical editor output (HTML round-trips through Lexical's node model, which drops non-whitelisted markup; content is only rendered inside the admin editor)
- [x] Input sanitization prevents SQL injection (SQLAlchemy parameterized queries; verified by `test_search_with_sql_metacharacters_is_treated_as_text`)
- [x] XSS prevention in Lexical editor output (verified by the E2E hostile-HTML test: scripts, event handlers and `javascript:` links are stripped by the node-model round trip and nothing executes)
### Performance Considerations
- Search with 10,000 items: <2 seconds response time