ixml parser: skip a DOCTYPE and a processing instruction - #1232
Merged
larshp merged 1 commit intoSep 15, 2026
Merged
Conversation
Both ended in the tag branch, where the tag regex does not match them and the parse dies in `ASSERT ls_match-offset = 0` - an assertion, so no CATCH cx_root absorbs it. A document that names its DTD, or that carries a stylesheet instruction ahead of the root element, could not be read at all. The xml declaration was already skipped, by a branch that matches '<?xml *' and then looks for "?>" - which is what every processing instruction ends with, so the pattern is now '<?*' and the same three lines serve both. A DOCTYPE gets its own branch: it ends at its ">", or at "]>" when it carries an internal subset, whose own ">" is not the end of the declaration. Tests: a DOCTYPE with a system identifier, one with an internal subset, a stylesheet instruction before the root element, and an instruction between two elements. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKSWLpid4QLV6XWAoPixbb
oblomov-dev
force-pushed
the
claude/nifty-meitner-ema3y8-doctype-pi
branch
from
September 15, 2026 13:00
c5432f3 to
e2e0fc8
Compare
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.
What is wrong
Neither has a branch of its own, so both reach the branch for a start or close
tag, where the tag regex does not match them and the parse dies in
ASSERT ls_match-offset = 0— an assertion, so noCATCH cx_rootabsorbs it:A document that names its DTD, or that carries a stylesheet instruction ahead
of the root element, cannot be read at all — and both stand where they stand
in plenty of files that are otherwise ordinary XML.
The change
The processing instruction needs no new code. The xml declaration was
already skipped by a branch that matches
'<?xml *'and then looks for?>— and
?>is what every processing instruction ends with, so the patternbecomes
'<?*'and the same three lines serve both:The DOCTYPE gets a branch of its own. It ends at its
>, except when itcarries an internal subset — there the
>of the subset is not the end of thedeclaration, and
]>is:Neither carries content of the document, so neither becomes a node — the same
shape as the comment in #1230.
Tests
parse_doctype—<!DOCTYPE note SYSTEM "note.dtd">before the rootparse_doctype_subset—<!DOCTYPE note [<!ELEMENT note (#PCDATA)>]>, wherethe
>inside the subset must not end the declarationparse_processing_instruction— a stylesheet instruction before the rootparse_instruction_in_element—<?target data?>between two elementsnpm testis green:abaplint: 0 issue(s) found, 735 file(s) analyzed, andthe full unit run passes.