mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
When constructing the JSON Path for the "fullpath" column of the
json_tree() and json_each() table-valued functions, be sure to quote object labels where necessary. FossilOrigin-Name: 0fbbe7881cadf0b3c211653c7a0797e0a90c7c24da78ecc8a27140c05f89f2ed
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sthe\sJSON\sPath\sparser\sso\sthat\sit\swill\saccept\szero-length\sobject\slabels.\n[forum/forumpost/c082aeab43|Forum\sthread\sc082aeab43].
|
C When\sconstructing\sthe\sJSON\sPath\sfor\sthe\s"fullpath"\scolumn\sof\sthe\njson_tree()\sand\sjson_each()\stable-valued\sfunctions,\sbe\ssure\sto\squote\nobject\slabels\swhere\snecessary.
|
||||||
D 2022-04-04T14:24:14.310
|
D 2022-04-04T15:15:45.616
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@@ -513,7 +513,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
|||||||
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
|
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
|
||||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||||
F src/insert.c c4fc48e6f38cc415262652407949771ce4e6f8f0c7330f872e44a0677f3ad602
|
F src/insert.c c4fc48e6f38cc415262652407949771ce4e6f8f0c7330f872e44a0677f3ad602
|
||||||
F src/json.c 37d4b68b52440653e9a8ffab13e9d5c282f01d4d6c1ba763aaa36c72671d9988
|
F src/json.c 7749b98c62f691697c7ee536b570c744c0583cab4a89200fdd0fc2aa8cc8cbd6
|
||||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||||
F src/loadext.c 2ecb1441f9b1c22e9e022ee0776e67d259facf34b56ba892b206f0a294ee6f8c
|
F src/loadext.c 2ecb1441f9b1c22e9e022ee0776e67d259facf34b56ba892b206f0a294ee6f8c
|
||||||
F src/main.c 89dfd569b4fbcab65281b3c6d636b887b2cb23cbaa16f8c6b67062862144c927
|
F src/main.c 89dfd569b4fbcab65281b3c6d636b887b2cb23cbaa16f8c6b67062862144c927
|
||||||
@@ -1945,8 +1945,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P e0305e640b9078c7eed9ab0bcc14f4515b54e7cd9ade3306bc2d1660f05b2725
|
P 84fe95d2a5b4d232d657e3b8110027a698a9bcd597f205cc535cfa97bc299f21
|
||||||
R b7b1f674d3bb83fa7d01b3c971c6fb98
|
R 970c08a76dac53f29009856eb6ab9f31
|
||||||
U drh
|
U drh
|
||||||
Z 9f0444d3701a4ee2277aeb80cbb65f96
|
Z feea099ba66960be6a93d634e84b651a
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
84fe95d2a5b4d232d657e3b8110027a698a9bcd597f205cc535cfa97bc299f21
|
0fbbe7881cadf0b3c211653c7a0797e0a90c7c24da78ecc8a27140c05f89f2ed
|
||||||
35
src/json.c
35
src/json.c
@@ -2275,6 +2275,33 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
|
|||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Append an object label to the JSON Path being constructed
|
||||||
|
** in pStr.
|
||||||
|
*/
|
||||||
|
static void jsonAppendObjectPathElement(
|
||||||
|
JsonString *pStr,
|
||||||
|
JsonNode *pNode
|
||||||
|
){
|
||||||
|
int jj, nn;
|
||||||
|
const char *z;
|
||||||
|
assert( pNode->eType==JSON_STRING );
|
||||||
|
assert( pNode->jnFlags & JNODE_LABEL );
|
||||||
|
assert( pNode->eU==1 );
|
||||||
|
z = pNode->u.zJContent;
|
||||||
|
nn = pNode->n;
|
||||||
|
assert( nn>=2 );
|
||||||
|
assert( z[0]=='"' );
|
||||||
|
assert( z[nn-1]=='"' );
|
||||||
|
if( nn>2 && sqlite3Isalpha(z[1]) ){
|
||||||
|
for(jj=2; jj<nn-1 && sqlite3Isalnum(z[jj]); jj++){}
|
||||||
|
if( jj==nn-1 ){
|
||||||
|
z++;
|
||||||
|
nn -= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsonPrintf(nn+2, pStr, ".%.*s", nn, z);
|
||||||
|
}
|
||||||
|
|
||||||
/* Append the name of the path for element i to pStr
|
/* Append the name of the path for element i to pStr
|
||||||
*/
|
*/
|
||||||
static void jsonEachComputePath(
|
static void jsonEachComputePath(
|
||||||
@@ -2299,10 +2326,7 @@ static void jsonEachComputePath(
|
|||||||
}else{
|
}else{
|
||||||
assert( pUp->eType==JSON_OBJECT );
|
assert( pUp->eType==JSON_OBJECT );
|
||||||
if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--;
|
if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--;
|
||||||
assert( pNode->eType==JSON_STRING );
|
jsonAppendObjectPathElement(pStr, pNode);
|
||||||
assert( pNode->jnFlags & JNODE_LABEL );
|
|
||||||
assert( pNode->eU==1 );
|
|
||||||
jsonPrintf(pNode->n+1, pStr, ".%.*s", pNode->n-2, pNode->u.zJContent+1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2373,8 +2397,7 @@ static int jsonEachColumn(
|
|||||||
if( p->eType==JSON_ARRAY ){
|
if( p->eType==JSON_ARRAY ){
|
||||||
jsonPrintf(30, &x, "[%d]", p->iRowid);
|
jsonPrintf(30, &x, "[%d]", p->iRowid);
|
||||||
}else if( p->eType==JSON_OBJECT ){
|
}else if( p->eType==JSON_OBJECT ){
|
||||||
assert( pThis->eU==1 );
|
jsonAppendObjectPathElement(&x, pThis);
|
||||||
jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonResult(&x);
|
jsonResult(&x);
|
||||||
|
|||||||
Reference in New Issue
Block a user