refactor: consolidate QTIEditor XML/HTML parsing on parseXML#6045
Open
rtibblesbot wants to merge 1 commit into
Open
refactor: consolidate QTIEditor XML/HTML parsing on parseXML#6045rtibblesbot wants to merge 1 commit into
rtibblesbot wants to merge 1 commit into
Conversation
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
marked this pull request as ready for review
July 16, 2026 19:19
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.
Summary
QTIEditor code parsed markup two ways:
parseXML, which surfaces malformed input as a thrown error, and barenew DOMParser()calls that silently proceed on a broken document. This consolidates parsing ontoparseXML, which now takes amimeTypeargument (default'text/xml') so HTML-fragment callers can parse leniently while XML callers keep theparsererrorfailure check.References
Follow-up from #6012. Closes #6044.
Reviewer guidance
serialization/parseItem.js:16— theparsererrorcheck is gated onmimeType === 'text/xml'; confirm an HTML input literally containing a<parsererror>element cannot trip it.serialization/qti/QTISanitizer.js:96—stripTagsnow routes throughparseXML('text/html'); check it stays lenient and never throws on sanitizer input.serialization/qti/__tests__/testUtils.js:14— the helper still returnsdocumentElement(anElement), not theDocument, 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?
🟡 Waiting for feedback
Last updated: 2026-07-16 19:19 UTC