]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Minor fixes to to the JSON% parser.
authordrh <>
Sat, 29 Apr 2023 12:13:27 +0000 (12:13 +0000)
committerdrh <>
Sat, 29 Apr 2023 12:13:27 +0000 (12:13 +0000)
FossilOrigin-Name: 2fe684cdcdc3cab4ec3348ca5aa5948e4472c562b739c29faebcb77397f8d969

manifest
manifest.uuid
src/json.c

index 5893cfd206a3a0700a68d303e62ea9870acf4720..db8aa3f3d874b48d6e5ca442058b20a7917d4112 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Correctly\srecognize\san\sisolated\sU+feff\sas\sa\sspace\scharacter\sin\sJSON5.
-D 2023-04-29T00:59:22.682
+C Minor\sfixes\sto\sto\sthe\sJSON%\sparser.
+D 2023-04-29T12:13:27.600
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -594,7 +594,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 3535ddb77b6bea2374a1ca5dad44cf616969bf202f8143c76bc9d1e38d1b587a
+F src/json.c a25afd49aba4a2ac6b5c0fdabd82f376beccdec18f1946e66143bdb51fb1be33
 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
 F src/loadext.c be5af440f3192c58681b5d43167dbca3ccbfce394d89faa22378a14264781136
 F src/main.c 09bc5191f75dc48fc4dfddda143cb864c0c3dbc3297eb9a9c8e01fea58ff847d
@@ -2067,8 +2067,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 c736b77a2fc5f8f2ba8f770adf05443dfdc3a9847ee519f411e661f76756d611
-R dbfd99e9ae655ae239188884ec879742
+P 4473dc8e3ad18bb6185ed4a819baf881a7d26ac74bc70fae6ba23a0030be8316
+R c6f6cd1aa30c85d050651bc2038ace97
 U drh
-Z 9ebd8716513a39a289a7550b0949e896
+Z 73c28292d33e23cb810b7dd1773fc296
 # Remove this line to create a well-formed Fossil manifest.
index dc0a2012c67686d44e3f2db5f1f79a81a4348efd..fc7993d0064ab565a689363d0bbd1fc85856a3d5 100644 (file)
@@ -1 +1 @@
-4473dc8e3ad18bb6185ed4a819baf881a7d26ac74bc70fae6ba23a0030be8316
\ No newline at end of file
+2fe684cdcdc3cab4ec3348ca5aa5948e4472c562b739c29faebcb77397f8d969
\ No newline at end of file
index deeb107671bf20fc504beba4a608eefe075357cd..32a52cf1eef8e0ef67e50978521eb4bb10f6622f 100644 (file)
@@ -377,10 +377,9 @@ static void jsonAppendNormalizedInt(JsonString *p, const char *zIn, u32 N){
       int rc = sqlite3DecOrHexToI64(zIn, &i);
       if( rc<=1 ){
         jsonPrintf(100,p,"%lld",i);
-      }else if( rc==2 ){
-        jsonAppendRaw(p, "9.0e999", 7);
       }else{
-        jsonAppendRaw(p, "9223372036854775808", 18);
+        assert( rc==2 );
+        jsonAppendRaw(p, "9.0e999", 7);
       }
       return;
     }
@@ -1109,7 +1108,10 @@ json_parse_restart:
       }
       if( pParse->oom ) return -1;
       pNode = &pParse->aNode[pParse->nNode-1];
-      if( pNode->eType!=JSON_STRING ) return -1;
+      if( pNode->eType!=JSON_STRING ){
+        pParse->iErr = j;
+        return -1;
+      }
       pNode->jnFlags |= JNODE_LABEL;
       j = x;
       if( z[j]==':' ){
@@ -1249,7 +1251,6 @@ json_parse_restart:
           jnFlags |= (JNODE_ESCAPE|JNODE_JSON5);
           pParse->has5 = 1;
         }else if( c=='\r' ){
-          j++;
           if( z[j+1]=='\n' ) j++;
           jnFlags |= (JNODE_ESCAPE|JNODE_JSON5);
           pParse->has5 = 1;
@@ -1339,10 +1340,7 @@ json_parse_restart:
         }
       }else{
         if( !sqlite3Isdigit(z[i+1]) ){
-          if( z[i+1]=='I'
-           && (c=='-' || c=='+')
-           && strncmp(&z[i+1], "Infinity",8)==0
-          ){
+          if( z[i+1]=='I' && strncmp(&z[i+1], "Infinity",8)==0 ){
             if( z[i]=='-' ){
               jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999");
             }else{
@@ -1354,7 +1352,6 @@ json_parse_restart:
           /* Non-standard JSON and JSON5:  Allow "Inf" as an alternative
           ** spelling for "Infinity" and allow it to be in any case. */
           if( (z[i+1]=='I' || z[i+1]=='i')
-           && (c=='-' || c=='+')
            && sqlite3StrNICmp(&z[i+1], "inf",3)==0
           ){
             if( z[i]=='-' ){
@@ -2971,8 +2968,8 @@ static void jsonAppendObjectPathElement(
   nn = pNode->n;
   if( (pNode->jnFlags & JNODE_RAW)==0 ){
     assert( nn>=2 );
-    assert( z[0]=='"' );
-    assert( z[nn-1]=='"' );
+    assert( z[0]=='"' || z[0]=='\'' );
+    assert( z[nn-1]=='"' || z[0]=='\'' );
     if( nn>2 && sqlite3Isalpha(z[1]) ){
       for(jj=2; jj<nn-1 && sqlite3Isalnum(z[jj]); jj++){}
       if( jj==nn-1 ){