Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing XML tag named <constructor> #468

Closed
5 of 6 tasks
RedMser opened this issue May 24, 2022 · 1 comment
Closed
5 of 6 tasks

Error parsing XML tag named <constructor> #468

RedMser opened this issue May 24, 2022 · 1 comment
Labels
bug Pending Pending to be confirmed by user/author for some check/update/implementation

Comments

@RedMser
Copy link

RedMser commented May 24, 2022

  • 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
@github-actions
Copy link

I'm glad you find this repository helpful. I'll try to address your issue ASAP. You can watch the repo for new changes or star it.

@amitguptagwl amitguptagwl added bug Pending Pending to be confirmed by user/author for some check/update/implementation labels May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Pending Pending to be confirmed by user/author for some check/update/implementation
Projects
None yet
Development

No branches or pull requests

2 participants