From: drh <> Date: Sun, 30 Apr 2023 19:45:25 +0000 (+0000) Subject: All JSON to understand floating point literals "Inf" and "QNaN" and "SNaN" in X-Git-Tag: version-3.42.0~73^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4a398c317d919321205668b010a4955e2325242c;p=thirdparty%2Fsqlite.git All JSON to understand floating point literals "Inf" and "QNaN" and "SNaN" in any case, without the SQLITE_EXTENDED_NAN_INF compile-time option. This extension is always available. FossilOrigin-Name: fb551145e0d84213b3343dc1bc7db70c898b9dea24a72b968240617f4b52d821 --- diff --git a/manifest b/manifest index c7969eb46e..0b4e7c7276 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sthe\sjson_valid()\sfunction.\s\sChange\sthe\sname\sof\sjson_error()\sto\njson_error_position().\s\sUse\s"NOT\sjson_error_position(X)"\sas\sa\ssubstitute\nfor\s"json_valid5(X)". -D 2023-04-30T19:34:41.159 +C All\sJSON\sto\sunderstand\sfloating\spoint\sliterals\s"Inf"\sand\s"QNaN"\sand\s"SNaN"\sin\nany\scase,\swithout\sthe\sSQLITE_EXTENDED_NAN_INF\scompile-time\soption.\s\sThis\nextension\sis\salways\savailable. +D 2023-04-30T19:45:25.975 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -595,7 +595,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 d216510dbb7900072e4a0cbb1273a21e0a20db57da405b4397abb236a2f30392 +F src/json.c bd22944b15d786a7a17f0faa672cdb3abeef1b59c505684df64caaca2a18a03a F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c be5af440f3192c58681b5d43167dbca3ccbfce394d89faa22378a14264781136 F src/main.c 09bc5191f75dc48fc4dfddda143cb864c0c3dbc3297eb9a9c8e01fea58ff847d @@ -2068,8 +2068,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 30d12edebad9b097cd5f0da355304d1cb2f8b70d7c7dff378fd7ad7c8ebf9279 -R 5a03c0d318d1b5343d158677e6158a89 +P 34c4e900a9cc51630eeaf01deef74bf5b18d66e0ab1dc61a2023ac8f837a5197 +R 6addb4498a8cf4456a809d957c22b7a6 U drh -Z 50768d32c83122dec00455a3ce19a1c8 +Z 050299ed4706f61a98d79f7a5528f481 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fa442e6283..db3c346403 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -34c4e900a9cc51630eeaf01deef74bf5b18d66e0ab1dc61a2023ac8f837a5197 \ No newline at end of file +fb551145e0d84213b3343dc1bc7db70c898b9dea24a72b968240617f4b52d821 \ No newline at end of file diff --git a/src/json.c b/src/json.c index 8fa08d2443..c221193282 100644 --- a/src/json.c +++ b/src/json.c @@ -1029,8 +1029,6 @@ static int json5Whitespace(const char *zIn){ return n; } - -#ifdef SQLITE_EXTENDED_NAN_INF /* ** Extra floating-point literals to allow in JSON. */ @@ -1049,7 +1047,6 @@ static const struct NanInfName { { 'q', 'Q', 4, JSON_NULL, 4, "QNaN", "null" }, { 's', 'S', 4, JSON_NULL, 4, "SNaN", "null" }, }; -#endif /* SQLITE_EXTENDED_NAN_INF */ /* ** Parse a single JSON value which begins at pParse->zJson[i]. Return the @@ -1336,28 +1333,20 @@ json_parse_restart: } }else{ if( !sqlite3Isdigit(z[i+1]) ){ - if( z[i+1]=='I' && strncmp(&z[i+1], "Infinity",8)==0 ){ - if( z[i]=='-' ){ - jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999"); - }else{ - jsonParseAddNode(pParse, JSON_REAL, 7, "9.0e999"); - } - return i+9; - } -#ifdef SQLITE_EXTENDED_NAN_INF - /* Non-standard JSON and JSON5: Allow "Inf" as an alternative - ** spelling for "Infinity" and allow it to be in any case. */ + /* JSON5 allows for "+Infinity" and "-Infinity" using exactly + ** that case. SQLite also allows these in any case and it allows + ** "+inf" and "-inf". */ if( (z[i+1]=='I' || z[i+1]=='i') && sqlite3StrNICmp(&z[i+1], "inf",3)==0 ){ + pParse->hasNonstd = 1; if( z[i]=='-' ){ jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999"); }else{ jsonParseAddNode(pParse, JSON_REAL, 7, "9.0e999"); } - return i+4; + return i + (sqlite3StrNICmp(&z[i+4],"inity",5)==0 ? 9 : 4); } -#endif if( z[i+1]=='.' ){ pParse->hasNonstd = 1; jnFlags |= JNODE_JSON5; @@ -1433,24 +1422,6 @@ json_parse_restart: jsonParseAddNode(pParse, seenDP | (jnFlags<<8), j - i, &z[i]); return j; } - case 'N': { - if( strncmp(&z[i],"NaN",3)==0 ){ - jsonParseAddNode(pParse, JSON_NULL, 4, "null"); - pParse->hasNonstd = 1; - return i+3; - } - pParse->iErr = i; - return -1; - } - case 'I': { - if( strncmp(&z[i],"Infinity",8)==0 ){ - jsonParseAddNode(pParse, JSON_REAL, 7, "9.0e999"); - pParse->hasNonstd = 1; - return i+8; - } - pParse->iErr = i; - return -1; - } case '}': { pParse->iErr = i; return -2; /* End of {...} */ @@ -1497,7 +1468,6 @@ json_parse_restart: return -1; } default: { -#ifdef SQLITE_EXTENDED_NAN_INF int k, nn; c = z[i]; for(k=0; khasNonstd = 1; return i + nn; } -#endif pParse->iErr = i; return -1; /* Syntax error */ }