Clarify std/json quirk_allow_backslash_x semantics

This commit is contained in:
Nigel Tao committed 2020-04-08 11:08:01 +10:00
1 parent d83bd8d036
commit df3acfbb21
2 files changed
+15 -3

No files matched your search

+11 -3
View File
@@ -75,14 +75,22 @@ pub const quirk_allow_backslash_single_quote base.u32 = 0x4909_9400 | 0x06
pub const quirk_allow_backslash_v base.u32 = 0x4909_9400 | 0x07
// When this quirk is enabled, e.g. "abc\xeFz" is accepted as a JSON string,
// decoding to 5 bytes: 0x61, 0x62, 0x63, 0xEF and 0x7A. There are exactly 2
// encoded bytes after each "\x".
// There are exactly 2 encoded bytes after each "\x".
//
// "\x", "\x9", "\x9$" and "\X99" are all still rejected.
//
// It is up to the caller how to interpret the two hexadecimal digits. There
// are two sensible choices: as a byte or as a Unicode code point.
//
// As a byte means decoding to 5 bytes: 0x61, 0x62, 0x63, 0xEF and 0x7A.
// Decoded strings are byte strings, no longer guaranteed to be valid UTF-8 and
// even if the overall byte string is valid UTF-8, tokens are also no longer
// guaranteed to split on UTF-8 boundaries.
//
// "\x", "\x9", "\x9$" and "\X99" are all still rejected.
// As a Unicode code point means decoding to 6 bytes: 0x61, 0x62, 0x63, 0xC3,
// 0xAF and 0x7A. The UTF-8 encoding of U+00EF LATIN SMALL LETTER I WITH
// DIAERESIS is the two byte sequence (0xC3, 0xAF). Decoded strings are still
// valid UTF-8 and tokens still split on UTF-8 boundaries.
pub const quirk_allow_backslash_x base.u32 = 0x4909_9400 | 0x08
// When this quirk is enabled, e.g. "abc\0z" is accepted as a JSON string,