Skip to content

Error parsing XML tag named <constructor> #468

@RedMser

Description

@RedMser
  • 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

If XML contains a tag named <constructor>, an invalid object gets added to the output.
This does not happen if an attribute named constructor exists (and disabling any name prefix).

I traced it back to node2json.js:compress() (input into the function was fine, but output was problematic).

Code

import { XMLParser } from "fast-xml-parser";

const xml = `<root><constructor /></root>`;
const json = new XMLParser().parse(xml);
console.log(json);

Output

{ root: { constructor: [ [Function: Object], '' ] } }

Expected data

{ root: { constructor: '' } }

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/implementationbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions