Quote a value for an error message, as JSON.stringify does, and also escape what it
leaves raw although a terminal acts on it: DEL, the C1 controls, every Unicode
format character (bidi overrides, zero-width characters) and the line and paragraph
separators U+2028/U+2029, which a viewer may break the line at. A filter value is echoed
in messages; a zero-width space in it made the refused value look valid, and an override
would reorder the rest of the line ("Trojan Source"). A value longer than
MAX_MESSAGE_VALUE_LENGTH characters is cut, and the "…" goes after the closing quote
("AAAA"…), so it does not read as part of the value. The quoted part stays a valid JSON
string, and a lone surrogate is escaped by JSON.stringify itself.
Quote a value for an error message, as
JSON.stringifydoes, and also escape what it leaves raw although a terminal acts on it: DEL, the C1 controls, every Unicode format character (bidi overrides, zero-width characters) and the line and paragraph separators U+2028/U+2029, which a viewer may break the line at. A filter value is echoed in messages; a zero-width space in it made the refused value look valid, and an override would reorder the rest of the line ("Trojan Source"). A value longer than MAX_MESSAGE_VALUE_LENGTH characters is cut, and the "…" goes after the closing quote ("AAAA"…), so it does not read as part of the value. The quoted part stays a valid JSON string, and a lone surrogate is escaped byJSON.stringifyitself.