Skip to content

XMLValidator accepts a literal ]]> in element text #901

Open

Description

@agammann
  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try the online tool?
  • Have you checked the docs for helpful APIs and examples?

Description

On 5.11.2 (current master at cf66a9658004553bc740616e6c7a4912e7e9aab6), XMLValidator accepts a literal ]]> in element text. The XML 1.0 CharData grammar excludes that sequence except when it closes a CDATA section.

Input

<a>]]></a> is the invalid input. <a>]]&gt;</a> is a valid control representing the same text.

Code

const { XMLParser, XMLValidator } = require('fast-xml-parser');
for (const xml of ['<a>]]></a>', '<a>]]&gt;</a>']) {
  console.log(xml, XMLValidator.validate(xml));
  console.log(new XMLParser().parse(xml, true));
}

Output

Both inputs return true from XMLValidator.validate; both parse with validation enabled as { a: ']]>' }. The online validator also reports “Valid XML” for the raw input. Python xml.etree.ElementTree rejects the raw input with ParseError at column 5 and accepts the escaped control.

Expected data

The raw delimiter should be rejected by validation (including parsing with validation=true), while the escaped control should remain valid.

Would you like to work on this issue?

  • Yes
  • No

Activity

  1. amitguptagwl commented on Nov 3, 2026

    @amitguptagwl
    Member

    plz check fast-xml-validator once

  2. agammann commented on Nov 4, 2026

    @agammann
    Author

    I checked the separate fast-xml-validator SyntaxValidator.validate on main at 335fcaf (package.json 1.4.2, Node 24.22.1). It returns true for the malformed <a>]]></a> and also for the valid escaped control <a>]]&gt;</a>. This case reproduces in the separate validator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions