Add std/json quirk_allow_backslash_new_line
diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c
index 678d6f7..f7409ff 100644
--- a/release/c/wuffs-unsupported-snapshot.c
+++ b/release/c/wuffs-unsupported-snapshot.c
@@ -6054,6 +6054,8 @@
#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 @@
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 b8ea358..eda8234 100644
--- a/std/json/decode_json.wuffs
+++ b/std/json/decode_json.wuffs
@@ -73,6 +73,8 @@
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 ec000c0..fdb14b2 100644
--- a/std/json/decode_quirks.wuffs
+++ b/std/json/decode_quirks.wuffs
@@ -36,6 +36,17 @@
// 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 a3e520f..8ea6bc5 100644
--- a/test/c/std/json.c
+++ b/test/c/std/json.c
@@ -1429,6 +1429,11 @@
.quirk = WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_E,
},
{
+ .want = 0x0A,
+ .str = "\"\\\n\"",
+ .quirk = WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_NEW_LINE,
+ },
+ {
.want = 0x3F,
.str = "\"\\?\"",
.quirk = WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_QUESTION_MARK,