diff options
author | drh <> | 2025-05-10 17:09:53 +0000 |
---|---|---|
committer | drh <> | 2025-05-10 17:09:53 +0000 |
commit | 94e22bc07737e6b4ef0ba7a6a7c901a1c16d9edc (patch) | |
tree | 4f13962994c87aabf0b76f254207d67f01f889f3 /src | |
parent | 844b457950c1858dca3fc5ed8fb1bda464381a7f (diff) | |
download | sqlite-94e22bc07737e6b4ef0ba7a6a7c901a1c16d9edc.tar.gz sqlite-94e22bc07737e6b4ef0ba7a6a7c901a1c16d9edc.zip |
Provide the SQLITE_BUG_COMPATIBLE_20250510 compile-time option that restores
the JSON5 bug fixed in the previous check-in, in case some applications need
it for legacy compatibility.
FossilOrigin-Name: 491cf31904fdbc9567b838d1ba27901e75f8ea3a117043017d08354bb09f9711
Diffstat (limited to 'src')
-rw-r--r-- | src/json.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/json.c b/src/json.c index e1b019d78..ee4cf1cbc 100644 --- a/src/json.c +++ b/src/json.c @@ -1757,7 +1757,11 @@ json_parse_restart: || (c=='u' && jsonIs4Hex(&z[j+1])) ){ if( opcode==JSONB_TEXT ) opcode = JSONB_TEXTJ; }else if( c=='\'' || c=='v' || c=='\n' - || (c=='0' && !sqlite3Isdigit(z[j+1])) +#ifdef SQLITE_BUG_COMPATIBLE_20250510 + || (c=='0') /* Legacy bug compatible */ +#else + || (c=='0' && !sqlite3Isdigit(z[j+1])) /* Correct implementation */ +#endif || (0xe2==(u8)c && 0x80==(u8)z[j+1] && (0xa8==(u8)z[j+2] || 0xa9==(u8)z[j+2])) || (c=='x' && jsonIs2Hex(&z[j+1])) ){ @@ -2726,7 +2730,18 @@ static u32 jsonUnescapeOneChar(const char *z, u32 n, u32 *piOut){ case 't': { *piOut = '\t'; return 2; } case 'v': { *piOut = '\v'; return 2; } case '0': { + /* JSON5 requires that the \0 escape not be followed by a digit. + ** But SQLite did not enforce this restriction in versions 3.42.0 + ** through 3.49.2. That was a bug. But some applications might have + ** come to depend on that bug. Use the SQLITE_BUG_COMPATIBLE_20250510 + ** option to restore the old buggy behavior. */ +#ifdef SQLITE_BUG_COMPATIBLE_20250510 + /* Legacy bug-compatible behavior */ + *piOut = 0; +#else + /* Correct behavior */ *piOut = (n>2 && sqlite3Isdigit(z[2])) ? JSON_INVALID_CHAR : 0; +#endif return 2; } case '\'': |