-
-
Notifications
You must be signed in to change notification settings - Fork 208
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
5.6.1
Plugin version
6.1.0
Node.js version
23.11.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
15.6.1
Description
After updating fast-json-stringify
to 6.1.0, error messages which contain double-quotes ("
) are not correctly serialized to JSON when using a custom Validator Compiler which returns a FastifyValidationResult
that contains an errors
array.
This was introduced in #774 when the error serializer code was switched to use isWellFormed
, rather than evaluating against a regular expression. The regular expression which was present before:
/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/
Detected the following characters:
- Control characters
- Quotation marks
- Backslashes
The switch to only use isWellFormed
removes the backslash and quotation detection.
Link to code that reproduces the bug
https://github.com/Senney/fastify-fast-json-stringify-bug
Expected Behavior
Validation error messages which contain quotation marks should pass through JSON.stringify
as expected, or be escaped through other means.