Skip to content

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

Closed
@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

Activity

added
PendingPending to be confirmed by user/author for some check/update/implementation
on Jul 6, 2022
added a commit that references this issue on Jun 4, 2024

fix NaturalIntelligence#472: stopNode can have any special tag inside

b0af652
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

    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

        Participants

        @diegone@amitguptagwl

        Issue actions

          Exception while parsing quotes in CDATA in a stop node · Issue #472 · NaturalIntelligence/fast-xml-parser