Skip to content

refactor: consolidate QTIEditor XML/HTML parsing on parseXML#6045

Open
rtibblesbot wants to merge 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6044-f1044e
Open

refactor: consolidate QTIEditor XML/HTML parsing on parseXML#6045
rtibblesbot wants to merge 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6044-f1044e

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

QTIEditor code parsed markup two ways: parseXML, which surfaces malformed input as a thrown error, and bare new DOMParser() calls that silently proceed on a broken document. This consolidates parsing onto parseXML, which now takes a mimeType argument (default 'text/xml') so HTML-fragment callers can parse leniently while XML callers keep the parsererror failure check.

References

Follow-up from #6012. Closes #6044.

Reviewer guidance

  • serialization/parseItem.js:16 — the parsererror check is gated on mimeType === 'text/xml'; confirm an HTML input literally containing a <parsererror> element cannot trip it.
  • serialization/qti/QTISanitizer.js:96stripTags now routes through parseXML('text/html'); check it stays lenient and never throws on sanitizer input.
  • serialization/qti/__tests__/testUtils.js:14 — the helper still returns documentElement (an Element), not the Document, so its five declaration-spec consumers are unchanged.

AI usage

Used Claude Code to implement the change following a pre-approved plan with test-driven development. Verified with the full QTIEditor Jest suite and the pre-commit JS linter.


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks
@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-07-16 19:19 UTC

Give parseXML a mimeType parameter (default 'text/xml') with an XML-only
parsererror check, and route QTISanitizer.stripTags and the declaration
test helper through it instead of constructing their own DOMParser. The
HTML parser recovers silently and never emits a parsererror node, so the
failure check runs only for XML.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rtibblesbot
rtibblesbot marked this pull request as ready for review July 16, 2026 19:19
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.

[QTI] Consolidate QTIEditor DOM parsing on parseXML and support text/html

1 participant