Skip to content

fix: reject invalid content after the root element - #916

Open
blueDaydreaming725 wants to merge 1 commit into
NaturalIntelligence:masterfrom
blueDaydreaming725:fix/xml-epilog-validation
Open

blueDaydreaming725 wants to merge 1 commit into
NaturalIntelligence:masterfrom
blueDaydreaming725:fix/xml-epilog-validation

Conversation

@blueDaydreaming725

Copy link
Copy Markdown

Fixes #899.

XML's epilog permits whitespace, comments, and processing instructions, but not character references, CDATA, DOCTYPE, or another root element. The validator's text-scanning loop handled references and markup before applying its existing reachedRoot check. Self-closing roots also never marked that state.

This change rejects references and non-comment <!...> markup after the root, records when a self-closing root completes, and applies the existing multiple-root error to a following self-closing element. Valid epilog content and the same constructs inside the root remain supported.

Validation

Node 24.22.1 on macOS:

  • Added validator and validation-enabled parser regressions for paired and self-closing roots. The invalid cases pass incorrectly before the fix and are rejected afterward; comments, processing instructions, and whitespace remain valid.
  • npx jasmine spec/validator_spec.js — 68 specs, 0 failures.
  • npm test — 343 specs, 0 failures, 2 existing pending specs.
  • npm run test-types and npm run bundle pass.
  • The generated CJS bundle was exercised against all four invalid epilog forms and valid controls. Generated files are not included in this PR, matching recent source-only contributions.
  • npm run lint cannot start because its script references the absent benchmark/**/*.js path. A broader direct ESLint invocation also reports existing errors; neither is claimed as a passing lint check.

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.

XMLValidator accepts references, CDATA, and DOCTYPE after the root element

1 participant