Skip to content

Reject unmatched closing tags at document level - #1098

Open
Vryuz wants to merge 1 commit into
leethomason:masterfrom
Vryuz:codex/reject-unmatched-document-end-tags
Open

Vryuz wants to merge 1 commit into
leethomason:masterfrom
Vryuz:codex/reject-unmatched-document-end-tags

Conversation

@Vryuz

@Vryuz Vryuz commented Oct 7, 2026

Copy link
Copy Markdown

Inputs such as </data>, an XML declaration followed by </data>, or <data/> followed by </data> currently return XML_SUCCESS. When ParseDeep encounters a closing element without a parent end-tag recipient, report XML_ERROR_MISMATCHED_ELEMENT at that closing tag's line and return failure. Nested closing-tag transfer and node cleanup stay unchanged.

Fixes #972.

Regression coverage includes closing tags after a declaration, a root, text, and comments, plus document cleanup/reuse and accepted fragment controls. The older #291 crash test uses the malformed input &#0</a>; it now expects a mismatch and still calls Print. A separate accepted <a>&#0</a> control retains coverage of lazy numeric-reference processing during printing.

Validation on Ubuntu with GCC 13.3:

  • Final tests against the original parser: 546 checks pass, 24 fail.
  • Debug and Release CTest runs: 570 checks pass, 0 fail in each.
  • Full ASan/UBSan CTest run with leak detection enabled: 570 checks pass, no findings.

The behavior change is limited to unmatched document-level closing tags. Existing supported text/multiple-element fragments remain accepted; no public API or ABI changes are introduced.

This branch has not been deployed

No deployments
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.

Error() returns false for corrupted XML (when there is no starting tag)

1 participant