From: drh <> Date: Thu, 5 Oct 2023 18:09:12 +0000 (+0000) Subject: Change the json_valid(X) routine to return true whenever X is a blob that X-Git-Tag: version-3.45.0~116^2~109 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b6cfb79068f20f4df34322139ef7c0b9d58ea2c;p=thirdparty%2Fsqlite.git Change the json_valid(X) routine to return true whenever X is a blob that could plausibly be a valid JSONB. FossilOrigin-Name: 425f0b85a6f8ad0604c4a5faa18efb90436fedb1fe2612a559147c62cff8b7e7 --- diff --git a/manifest b/manifest index d1a8859d10..3b52cf09de 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\stext-to-JSONB\sparser\sso\sthat\sit\shandles\ssome\sJSON5\sfloating\spoint\nliterals\scorrectly. -D 2023-10-05T17:52:39.456 +C Change\sthe\sjson_valid(X)\sroutine\sto\sreturn\strue\swhenever\sX\sis\sa\sblob\sthat\ncould\splausibly\sbe\sa\svalid\sJSONB. +D 2023-10-05T18:09:12.028 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -670,7 +670,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 5b00523c237b93a0c0f644bfa2adc5cf2bf381e3a2a02791a03a1765d6ddac67 +F src/json.c 436cc9b8a4cfef2ac5c8547fcf8acff8a91b9fb9b9d070ebf240e8ab871f23a7 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 98cfba10989b3da6f1807ad42444017742db7f100a54f1032af7a8b1295912c0 F src/main.c 618aeb399e993cf561864f4b0cf6a331ee4f355cf663635f8d9da3193a46aa40 @@ -2124,8 +2124,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 487781be8a93d9b8d870efb9f25822bb4bbcf9d39d571d1017e9c29043ea515d -R 6dd39d4bbce9b9abcc4c4c2e13a0b712 +P 564edb3b6dd752e09e445e3a25c2f5394ceede2a2cdff251d6433dadc0b3644f +R 99ed34df38b98d618529ef152948a4c8 U drh -Z 37a9884f8448701e772294f223618265 +Z 05060c3a4460d98ce1ee0304660e3eea # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 233800a07f..8c16d8482a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -564edb3b6dd752e09e445e3a25c2f5394ceede2a2cdff251d6433dadc0b3644f \ No newline at end of file +425f0b85a6f8ad0604c4a5faa18efb90436fedb1fe2612a559147c62cff8b7e7 \ No newline at end of file diff --git a/src/json.c b/src/json.c index ba701ba68e..3c179ac16a 100644 --- a/src/json.c +++ b/src/json.c @@ -4812,8 +4812,14 @@ static void jsonTypeFunc( /* ** json_valid(JSON) ** -** Return 1 if JSON is a well-formed canonical JSON string according -** to RFC-7159. Return 0 otherwise. +** Return 1 if the argument is one of: +** +** * A well-formed canonical JSON string according to RFC-8259 +** (without JSON5 enhancements), or +** +** * A BLOB that plausibly could be a JSONB value. +** +** Return 0 otherwise. */ static void jsonValidFunc( sqlite3_context *ctx, @@ -4829,6 +4835,10 @@ static void jsonValidFunc( #endif return; } + if( jsonFuncArgMightBeBinary(argv[0]) ){ + sqlite3_result_int(ctx, 1); + return; + } p = jsonParseCached(ctx, argv[0], 0, 0); if( p==0 || p->oom ){ sqlite3_result_error_nomem(ctx);