mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
The u.zJContent field of JsonNode for a string or label should NOT include
the quotation mark delimiters. Ever. This is an inefficiency that really ought to be fixed on trunk, but that can wait until this branch lands. FossilOrigin-Name: 96f545f6f839dab4829861361ee3d7a56840217c5f954f334616e77d23c5fe29
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
||||
C Additional\srefactoring\sand\scleanup.
|
||||
D 2023-09-29T16:37:22.006
|
||||
C The\su.zJContent\sfield\sof\sJsonNode\sfor\sa\sstring\sor\slabel\sshould\sNOT\sinclude\nthe\squotation\smark\sdelimiters.\s\sEver.\s\sThis\sis\san\sinefficiency\sthat\sreally\nought\sto\sbe\sfixed\son\strunk,\sbut\sthat\scan\swait\suntil\sthis\sbranch\slands.
|
||||
D 2023-09-29T19:47:25.994
|
||||
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 d7de85731741831d299cfd76520f6af7e72b3b175f3cbfe22d0454e8abbb6090
|
||||
F src/json.c 2112b76a0d0ed938df844dcac57170ef825c6fb92f0bb1e2c35360d77fa8abbd
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 98cfba10989b3da6f1807ad42444017742db7f100a54f1032af7a8b1295912c0
|
||||
F src/main.c 618aeb399e993cf561864f4b0cf6a331ee4f355cf663635f8d9da3193a46aa40
|
||||
@@ -2123,8 +2123,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 9b620d813ef483f1277c1683c5e926a882f07f3b90804dea0c91b325ff8e45a4
|
||||
R bcca84e0a588bc606d4e22707cc86ed4
|
||||
P 45dd1760875b1ad899a10189c6f5a0a9a0677903794fb5a06ffacd39952a7882
|
||||
R 0ad6f1d70a03e9858beb1d83ab248cfc
|
||||
U drh
|
||||
Z 4c6f8cb9c19d993b3edfba11c172dd33
|
||||
Z ecabd724f6e30a2efa3505d39eb1f7e4
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
@@ -1 +1 @@
|
||||
45dd1760875b1ad899a10189c6f5a0a9a0677903794fb5a06ffacd39952a7882
|
||||
96f545f6f839dab4829861361ee3d7a56840217c5f954f334616e77d23c5fe29
|
||||
44
src/json.c
44
src/json.c
@@ -435,7 +435,7 @@ static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){
|
||||
}
|
||||
}
|
||||
static void jsonAppendRawNZ(JsonString *p, const char *zIn, u32 N){
|
||||
assert( N>0 );
|
||||
if( N==0 ) return;
|
||||
if( N+p->nUsed >= p->nAlloc ){
|
||||
jsonStringExpandAndAppend(p,zIn,N);
|
||||
}else{
|
||||
@@ -557,8 +557,6 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){
|
||||
static void jsonAppendNormalizedString(JsonString *p, const char *zIn, u32 N){
|
||||
u32 i;
|
||||
jsonAppendChar(p, '"');
|
||||
zIn++;
|
||||
N -= 2;
|
||||
while( N>0 ){
|
||||
for(i=0; i<N && zIn[i]!='\\'; i++){}
|
||||
if( i>0 ){
|
||||
@@ -894,8 +892,9 @@ static void jsonRenderNodeAsText(
|
||||
}else if( pNode->jnFlags & JNODE_JSON5 ){
|
||||
jsonAppendNormalizedString(pOut, pNode->u.zJContent, pNode->n);
|
||||
}else{
|
||||
assert( pNode->n>0 );
|
||||
jsonAppendChar(pOut, '"');
|
||||
jsonAppendRawNZ(pOut, pNode->u.zJContent, pNode->n);
|
||||
jsonAppendChar(pOut, '"');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1118,7 +1117,7 @@ static void jsonReturnNodeAsSql(
|
||||
}else if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){
|
||||
/* JSON formatted without any backslash-escapes */
|
||||
assert( pNode->eU==1 );
|
||||
sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2,
|
||||
sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n,
|
||||
SQLITE_TRANSIENT);
|
||||
}else{
|
||||
/* Translate JSON formatted string into raw text */
|
||||
@@ -1135,7 +1134,7 @@ static void jsonReturnNodeAsSql(
|
||||
sqlite3_result_error_nomem(pCtx);
|
||||
break;
|
||||
}
|
||||
for(i=1, j=0; i<n-1; i++){
|
||||
for(i=0, j=0; i<n; i++){
|
||||
char c = z[i];
|
||||
if( c=='\\' ){
|
||||
c = z[++i];
|
||||
@@ -1705,7 +1704,7 @@ json_parse_restart:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
jsonParseAddNode(pParse, JSON_STRING | (jnFlags<<8), j+1-i, &z[i]);
|
||||
jsonParseAddNode(pParse, JSON_STRING | (jnFlags<<8), j-1-i, &z[i+1]);
|
||||
return j+1;
|
||||
}
|
||||
case 't': {
|
||||
@@ -2183,13 +2182,8 @@ static JsonParse *jsonParseCached(
|
||||
*/
|
||||
static int jsonLabelCompare(const JsonNode *pNode, const char *zKey, u32 nKey){
|
||||
assert( pNode->eU==1 );
|
||||
if( pNode->jnFlags & JNODE_RAW ){
|
||||
if( pNode->n!=nKey ) return 0;
|
||||
return strncmp(pNode->u.zJContent, zKey, nKey)==0;
|
||||
}else{
|
||||
if( pNode->n!=nKey+2 ) return 0;
|
||||
return strncmp(pNode->u.zJContent+1, zKey, nKey)==0;
|
||||
}
|
||||
}
|
||||
static int jsonSameLabel(const JsonNode *p1, const JsonNode *p2){
|
||||
if( p1->jnFlags & JNODE_RAW ){
|
||||
@@ -5169,27 +5163,29 @@ static void jsonAppendObjectPathElement(
|
||||
JsonString *pStr,
|
||||
JsonNode *pNode
|
||||
){
|
||||
int jj, nn;
|
||||
int nn;
|
||||
const char *z;
|
||||
int bNeedQuote = 0;
|
||||
assert( pNode->eType==JSON_STRING );
|
||||
assert( pNode->jnFlags & JNODE_LABEL );
|
||||
assert( pNode->eU==1 );
|
||||
z = pNode->u.zJContent;
|
||||
nn = pNode->n;
|
||||
if( (pNode->jnFlags & JNODE_RAW)==0 ){
|
||||
assert( nn>=2 );
|
||||
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 ){
|
||||
z++;
|
||||
nn -= 2;
|
||||
}
|
||||
}
|
||||
if( pNode->jnFlags & JNODE_RAW ){
|
||||
/* no-op */
|
||||
}else if( nn==0 || !sqlite3Isalpha(z[0]) ){
|
||||
bNeedQuote = 1;
|
||||
}else{
|
||||
int jj;
|
||||
for(jj=1; jj<nn && sqlite3Isalnum(z[jj]); jj++){}
|
||||
bNeedQuote = jj<nn;
|
||||
}
|
||||
if( bNeedQuote ){
|
||||
jsonPrintf(nn+4, pStr, ".\"%.*s\"", nn, z);
|
||||
}else{
|
||||
jsonPrintf(nn+2, pStr, ".%.*s", nn, z);
|
||||
}
|
||||
}
|
||||
|
||||
/* Append the name of the path for element i to pStr
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user