diff --git a/lib/serializer.js b/lib/serializer.js index 47c18f15..01dff2c1 100644 --- a/lib/serializer.js +++ b/lib/serializer.js @@ -141,11 +141,8 @@ module.exports = class Serializer { // eslint-disable-next-line for (var i = 0; i < len; i++) { point = str.charCodeAt(i) - if (point < 32) { - return JSON.stringify(str) - } - if (point >= 0xD800 && point <= 0xDFFF) { - // The current character is a surrogate. + if (point < 32 || (point >= 0xD800 && point <= 0xDFFF)) { + // The current character is non-printable characters or a surrogate. return JSON.stringify(str) } if (