The json_error_position() function now reports an approximate byte offset
to the problem in a JSONB if there is a problem. FossilOrigin-Name: 80d5d94dff6a2d2557039be3d7d47c1a6003c4b98defe0bd411acfeb963ad5dd
This commit is contained in:
parent
5a890b4ed2
commit
ad6bc61804
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C json_error_position()\snow\suses\sjsonValidityCheck()\sto\sfind\sthe\sapproximate\nposition\sof\san\serror\sin\sa\sJSONB\sblob.
|
||||
D 2023-12-11T20:44:21.543
|
||||
C The\sjson_error_position()\sfunction\snow\sreports\san\sapproximate\sbyte\soffset\nto\sthe\sproblem\sin\sa\sJSONB\sif\sthere\sis\sa\sproblem.
|
||||
D 2023-12-11T21:00:55.202
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -696,7 +696,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
||||
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
|
||||
F src/json.c 191626c46afe3325a01c1a77b7aef6b10b8dc8a76c38757adeca89e51a4248db
|
||||
F src/json.c 387dd9d7d63bac1e0068d66e8b40d86e1e2f0edc6930da28c67584c7a5a32872
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
|
||||
F src/main.c ce714ee501122c76eb2e69b292bebe443aba611fc3b88e6786eb910285515fe4
|
||||
@ -2153,8 +2153,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P c0d7f4520d839a268b3fd2474d0897a9832aa608bd6238b3e287fabecf07a350
|
||||
R 3b1676d0420fc714545bd48a8af4a295
|
||||
P c3d60cf7028a333b825d5b89516945a73e0c158ac81d8bcc117d21bfd98602c8
|
||||
R eef20549bb0818034c7a80cb1490f371
|
||||
U drh
|
||||
Z 901bf4bbda4e9c3a1530e623c45e3a19
|
||||
Z 99dd825f602cc4286df6f3fcbe1570d6
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
c3d60cf7028a333b825d5b89516945a73e0c158ac81d8bcc117d21bfd98602c8
|
||||
80d5d94dff6a2d2557039be3d7d47c1a6003c4b98defe0bd411acfeb963ad5dd
|
30
src/json.c
30
src/json.c
@ -1240,7 +1240,12 @@ static int jsonIs4HexB(const char *z, int *pOp){
|
||||
** error if a problem is detected. (In other words, if the error is at offset
|
||||
** 0, return 1).
|
||||
*/
|
||||
static u32 jsonbValidityCheck(JsonParse *pParse, u32 i, u32 iEnd, u32 iDepth){
|
||||
static u32 jsonbValidityCheck(
|
||||
const JsonParse *pParse, /* Input JSONB. Only aBlob and nBlob are used */
|
||||
u32 i, /* Start of element as pParse->aBlob[i] */
|
||||
u32 iEnd, /* One more than the last byte of the element */
|
||||
u32 iDepth /* Current nesting depth */
|
||||
){
|
||||
u32 n, sz, j, k;
|
||||
const u8 *z;
|
||||
u8 x;
|
||||
@ -1265,7 +1270,7 @@ static u32 jsonbValidityCheck(JsonParse *pParse, u32 i, u32 iEnd, u32 iDepth){
|
||||
j = i+n;
|
||||
if( z[j]=='-' ){
|
||||
j++;
|
||||
if( sz<2 ) return j;
|
||||
if( sz<2 ) return i+1;
|
||||
}
|
||||
k = i+n+sz;
|
||||
while( j<k ){
|
||||
@ -1284,7 +1289,7 @@ static u32 jsonbValidityCheck(JsonParse *pParse, u32 i, u32 iEnd, u32 iDepth){
|
||||
if( sz<4 ) return i+1;
|
||||
j++;
|
||||
}
|
||||
if( z[j]!='0' ) return j+1;
|
||||
if( z[j]!='0' ) return i+1;
|
||||
if( z[j+1]!='x' && z[j+1]!='X' ) return j+2;
|
||||
j += 2;
|
||||
k = i+n+sz;
|
||||
@ -1308,36 +1313,35 @@ static u32 jsonbValidityCheck(JsonParse *pParse, u32 i, u32 iEnd, u32 iDepth){
|
||||
if( sz<3 ) return i+1;
|
||||
}
|
||||
if( z[j]=='.' ){
|
||||
if( !sqlite3Isdigit(z[j+1]) ) return i+1;
|
||||
if( !sqlite3Isdigit(z[j+1]) ) return j+1;
|
||||
j += 2;
|
||||
seen = 1;
|
||||
}else if( z[j]=='0' && x==JSONB_FLOAT ){
|
||||
if( j+3>k ) return i+1;
|
||||
if( z[j+1]!='.' ) return i+1;
|
||||
j += 2;
|
||||
seen = 1;
|
||||
if( j+3>k ) return j+1;
|
||||
if( z[j+1]!='.' && z[j+1]!='e' && z[j+1]!='E' ) return j+1;
|
||||
j++;
|
||||
}
|
||||
for(; j<k; j++){
|
||||
if( sqlite3Isdigit(z[j]) ) continue;
|
||||
if( z[j]=='.' ){
|
||||
if( seen>0 ) return i+1;
|
||||
if( x==JSONB_FLOAT && (j==k-1 || !sqlite3Isdigit(z[j+1])) ){
|
||||
return i+1;
|
||||
return j+1;
|
||||
}
|
||||
seen = 1;
|
||||
continue;
|
||||
}
|
||||
if( z[j]=='e' || z[j]=='E' ){
|
||||
if( seen==2 ) return i+1;
|
||||
if( j==k-1 ) return i+1;
|
||||
if( seen==2 ) return j+1;
|
||||
if( j==k-1 ) return j+1;
|
||||
if( z[j+1]=='+' || z[j+1]=='-' ){
|
||||
j++;
|
||||
if( j==k-1 ) return i+1;
|
||||
if( j==k-1 ) return j+1;
|
||||
}
|
||||
seen = 2;
|
||||
continue;
|
||||
}
|
||||
return i+1;
|
||||
return j+1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user