mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
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
This commit is contained in:
17
src/json.c
17
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 '\'':
|
||||
|
Reference in New Issue
Block a user