Skip to content

JSON.parse in body parser fails silently when string has unescaped double quotes #20

Description

@rahulreddy

I ran into this issue when using a route to upload a file NSR was stripping out double quotes after parsing the body into request.post. After digging through, I found out that JSON.parse returns a string with the quotes stripped (it should either throw an error or return an object) even though the input is just a string. Please try the code below in console to replicate the error.

var str = '"hello"';
console.log(JSON.parse(str));
// returns hello removing the quotes

var str = '"hello';
console.log(JSON.parse(str));
// throws SynraxError exception as it should

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions