Skip to content

Exception while parsing quotes in CDATA in a stop node #472

@diegone

Description

@diegone
  • 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 online tool?

Description

Getting an exception in the specified scenario.

Input

<a>
  <b><![CDATA[']]></b>
  <b>'</b>
</a>

Code

const XMLParser = require('fast-xml-parser').XMLParser;
const parser = new XMLParser({ stopNodes: ["*.b"] });
console.dir(parser.parse("<a><b><![CDATA[']]></b><b>'</b></a>"));

Output

node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js:299
            if(!result) throw new Error(`Unexpected end of ${tagName}`);
                        ^
Error: Unexpected end of b
    at OrderedObjParser.parseXml (node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js:299:31)
    at XMLParser.parse (node_modules/fast-xml-parser/src/xmlparser/XMLParser.js:35:48)

expected data

{ a: { b: [ "'", "'" ] } }

Would you like to work on this issue?

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    PendingPending to be confirmed by user/author for some check/update/implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions