diff options
author | drh <> | 2023-04-27 16:57:14 +0000 |
---|---|---|
committer | drh <> | 2023-04-27 16:57:14 +0000 |
commit | 8ded1642009400732782d4030d8d4359064531d0 (patch) | |
tree | 2f922a4a234c6efdb22d67d9e50cb094e873dfce /src/json.c | |
parent | dbcea23976955b2aa36ca9eb92b0fe5315ef7665 (diff) | |
download | sqlite-8ded1642009400732782d4030d8d4359064531d0.tar.gz sqlite-8ded1642009400732782d4030d8d4359064531d0.zip |
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
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/json.c b/src/json.c index e508209fc..4ef53cd8a 100644 --- a/src/json.c +++ b/src/json.c @@ -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 ){ |