diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 678d6f78..f7409ffd 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -6054,6 +6054,8 @@ extern const char* wuffs_json__error__unsupported_recursion_depth; #define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_E 1225364483 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_NEW_LINE 1225364484 + #define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_QUESTION_MARK 1225364485 #define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_SINGLE_QUOTE 1225364486 @@ -21045,6 +21047,8 @@ wuffs_json__decoder__set_quirk_enabled(wuffs_json__decoder* self, self->private_impl.f_quirk_enabled_allow_backslash_capital_u = a_enabled; } else if (a_quirk == 1225364483) { self->private_impl.f_quirk_enabled_allow_backslash_etc[2] = a_enabled; + } else if (a_quirk == 1225364484) { + self->private_impl.f_quirk_enabled_allow_backslash_etc[3] = a_enabled; } else if (a_quirk == 1225364485) { self->private_impl.f_quirk_enabled_allow_backslash_etc[4] = a_enabled; } else if (a_quirk == 1225364486) { diff --git a/std/json/decode_json.wuffs b/std/json/decode_json.wuffs index b8ea3582..eda82341 100644 --- a/std/json/decode_json.wuffs +++ b/std/json/decode_json.wuffs @@ -73,6 +73,8 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) { this.quirk_enabled_allow_backslash_capital_u = args.enabled } else if args.quirk == quirk_allow_backslash_e { this.quirk_enabled_allow_backslash_etc[2] = args.enabled + } else if args.quirk == quirk_allow_backslash_new_line { + this.quirk_enabled_allow_backslash_etc[3] = args.enabled } else if args.quirk == quirk_allow_backslash_question_mark { this.quirk_enabled_allow_backslash_etc[4] = args.enabled } else if args.quirk == quirk_allow_backslash_single_quote { diff --git a/std/json/decode_quirks.wuffs b/std/json/decode_quirks.wuffs index ec000c0e..fdb14b28 100644 --- a/std/json/decode_quirks.wuffs +++ b/std/json/decode_quirks.wuffs @@ -36,6 +36,17 @@ pub const quirk_allow_backslash_capital_u base.u32 = 0x4909_9400 | 0x02 // equivalent to "abc\u001Bz", containing an ASCII Escape control character. pub const quirk_allow_backslash_e base.u32 = 0x4909_9400 | 0x03 +// When this quirk is enabled, e.g. ("abc\ +// z") is accepted as a JSON string, equivalent to "abc\nz". +// +// This allows for multi-line strings, if each new line is preceded by a +// backslash. This doesn't combine per se with quirk_allow_ascii_control_codes, +// but they have similar consequences. +// +// Any indentation following a new line is not stripped, but remains part of +// the decoded string. +pub const quirk_allow_backslash_new_line base.u32 = 0x4909_9400 | 0x04 + // When this quirk is enabled, e.g. "abc\?z" is accepted as a JSON string, // equivalent to "abc?z". pub const quirk_allow_backslash_question_mark base.u32 = 0x4909_9400 | 0x05 diff --git a/test/c/std/json.c b/test/c/std/json.c index a3e520fc..8ea6bc55 100644 --- a/test/c/std/json.c +++ b/test/c/std/json.c @@ -1428,6 +1428,11 @@ test_wuffs_json_decode_quirk_allow_backslash_etc() { .str = "\"\\e\"", .quirk = WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_E, }, + { + .want = 0x0A, + .str = "\"\\\n\"", + .quirk = WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_NEW_LINE, + }, { .want = 0x3F, .str = "\"\\?\"",