I believe that stringify-object
doesn't correctly escape special characters in strings. Consider the following program:
const stringifyObject = require('stringify-object');
const s = 'tab: \t newline: \n backslash: \\';
console.log(JSON.stringify(s)); // Output: "tab: \t newline: \n backslash: \\"
console.log(stringifyObject(s)); // Output: 'tab: newline: \n backslash: \'
I'd expect stringifyObject()
to give results similar to JSON.stringify()
, in that both should return a valid JavaScript expression. However, both the tab character and the backslash are not escaped, but are copied to the output verbatim.
In the case of the tab character, the resulting code is unexpected but still technically correct.
In the case of the backslash, the resulting code is no valid JavaScript any more, but leaves an unterminated string.
Only the newline character is escaped as expected.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too