Fix handling of reverse solidus in string literals. Allow decimal points

in floating point literals to occurs and the beginning or end of the mantissa.

FossilOrigin-Name: d92a6ab2871095ac66c60cfa15dbafa7b762f83d287d452f61792eb30cf5b26b
This commit is contained in:
drh 2023-04-27 16:57:14 +00:00
parent dbcea23976
commit 8ded164200
3 changed files with 35 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Fix\sthe\shandling\sof\sescape\ssolidus\sin\sthe\sJSON\sroutines.
D 2023-04-27T16:24:12.129
C Fix\shandling\sof\sreverse\ssolidus\sin\sstring\sliterals.\s\sAllow\sdecimal\spoints\nin\sfloating\spoint\sliterals\sto\soccurs\sand\sthe\sbeginning\sor\send\sof\sthe\smantissa.
D 2023-04-27T16:57:14.640
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -592,7 +592,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
F src/hwtime.h b638809e083b601b618df877b2e89cb87c2a47a01f4def10be4c4ebb54664ac7
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c a8de1db43335fc4946370a7a7e47d89975ad678ddb15078a150e993ba2fb37d4
F src/json.c cdf05600af31e37ad50924f39d7fa6227a7c9b94ea3d3690312cc1b7e15b36ef
F src/json.c d1a73af4f4185cfc355fa4b7be0cdc5cddd80b06da3d8ad3f966b8758e9027a1
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c be5af440f3192c58681b5d43167dbca3ccbfce394d89faa22378a14264781136
F src/main.c 09bc5191f75dc48fc4dfddda143cb864c0c3dbc3297eb9a9c8e01fea58ff847d
@ -2063,8 +2063,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 66da4bd4a30c390fa1a7960ce2edaef82e63971ecf33ffb6b906db9f278041c5
R 9748a62c2b5ef29db66fe80859611ec7
P 676877aca235e620ee12d10235dd6ad009d4968455ec170daeb1998b94a7e0a2
R 55fe1e7f7cae4da350b14dce9970e986
U drh
Z 8f82433213e0588347a902f584c3080a
Z eab22ac4584a027288ad76a2849798e8
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
676877aca235e620ee12d10235dd6ad009d4968455ec170daeb1998b94a7e0a2
d92a6ab2871095ac66c60cfa15dbafa7b762f83d287d452f61792eb30cf5b26b

View File

@ -398,6 +398,7 @@ static void jsonAppendNormalizedReal(JsonString *p, const char *zIn, u32 N){
}
for(i=0; i<N; i++){
if( zIn[i]=='.' && (i+1==N || !sqlite3Isdigit(zIn[i+1])) ){
i++;
jsonAppendRaw(p, zIn, i);
zIn += i;
N -= i;
@ -802,7 +803,7 @@ static void jsonReturn(
c = '\t';
}else if( c=='v' ){
c = '\v';
}else if( c=='\'' || c=='"' || c=='/' ){
}else if( c=='\'' || c=='"' || c=='/' || c=='\\' ){
/* pass through unchanged */
}else if( c=='0' ){
c = 0;
@ -1268,6 +1269,15 @@ json_parse_restart:
pParse->has5 = 1;
jnFlags = JNODE_JSON5;
goto parse_number;
case '.':
if( sqlite3Isdigit(z[i+1]) ){
pParse->has5 = 1;
jnFlags = JNODE_JSON5;
seenE = 0;
seenDP = 1;
goto parse_number_2;
}
return -1;
case '-':
case '0':
case '1':
@ -1303,6 +1313,7 @@ json_parse_restart:
}
}
}
parse_number_2:
for(j=i+1;; j++){
c = z[j];
if( c>='0' && c<='9' ) continue;
@ -1313,7 +1324,14 @@ json_parse_restart:
continue;
}
if( c=='e' || c=='E' ){
if( z[j-1]<'0' ) return -1;
if( z[j-1]<'0' ){
if( z[j-1]=='.' && j-2>=i && sqlite3Isdigit(z[j-2]) ){
pParse->has5 = 1;
jnFlags |= JNODE_JSON5;
}else{
return -1;
}
}
if( seenE ) return -1;
seenDP = seenE = 1;
c = z[j+1];
@ -1344,7 +1362,14 @@ json_parse_restart:
#endif
break;
}
if( z[j-1]<'0' ) return -1;
if( z[j-1]<'0' ){
if( z[j-1]=='.' && j-2>=i && sqlite3Isdigit(z[j-2]) ){
pParse->has5 = 1;
jnFlags |= JNODE_JSON5;
}else{
return -1;
}
}
jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT,
j - i, &z[i]);
if( jnFlags && !pParse->oom ){