NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.

Home Page:https://naturalintelligence.github.io/fast-xml-parser/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Properties from Object's prototype are including during XML creation

aparshin opened this issue · comments

  • 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 a custom property is added to Object's prototype, it is included in generated XML. It shouldn't happen because in some cases users can't control pollution of Object / Array prototypes.

Input

{a: 1}

Code

const { XMLBuilder } = require("fast-xml-parser");

// emulate pollution of Object's prototype
Object.prototype.something = 'strange';

const builder = new XMLBuilder();
const xml = builder.build({ a: 1 });

console.log(xml);

Output

<a>1</a><something>strange</something> 

Expected output

<a>1</a>

Would you like to work on this issue?

  • Yes
  • No

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.

Maybe #268 is somehow related to this issue...