promplate / partial-json-parser-js

Parse partial JSON generated by LLM
https://npmjs.com/partial-json
MIT License
76 stars 2 forks source link

Edge case with proto #8

Open jacobzim-stl opened 2 months ago

jacobzim-stl commented 2 months ago

I did some fuzz testing with this library and found an edge case.

The JSON string "{\"__proto__\": 0}" is correctly parsed by the native JSON library into { "__proto__": 0 }, but in this library it is parsed into {}.

To solve, in the parseObj function update obj[key] = value; to Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });

CNSeniorious000 commented 2 months ago

Thanks! I'm not very familiar with these JavaScript features, as I simply translated my Python implementation without a deep understanding of the JavaScript specifics. Would you mind creating a PR?