1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Correct handling of "raw" strings in JSON. This requires three test-case

changes in TH3 to add double-quotes to the path outputs from json_tree().
The new behavior is correct, I believe.

FossilOrigin-Name: ab2bf3e3596dfa7566f4a130adeccbef4056c7321181112a875477193583f30c
This commit is contained in:
drh
2023-10-06 23:02:06 +00:00
parent 6b8aa95c3c
commit 11aa2adca3
3 changed files with 22 additions and 20 deletions

View File

@@ -910,13 +910,7 @@ static void jsonRenderNodeAsText(
case JSON_STRING: {
assert( pNode->eU==1 );
if( pNode->jnFlags & JNODE_RAW ){
if( pNode->jnFlags & JNODE_LABEL ){
jsonAppendChar(pOut, '"');
jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n);
jsonAppendChar(pOut, '"');
}else{
jsonAppendString(pOut, pNode->u.zJContent, pNode->n);
}
jsonAppendString(pOut, pNode->u.zJContent, pNode->n);
}else if( pNode->jnFlags & JNODE_JSON5 ){
jsonAppendNormalizedString(pOut, pNode->u.zJContent, pNode->n);
}else{
@@ -1564,7 +1558,7 @@ json_parse_restart:
){
k++;
}
jsonParseAddNode(pParse, JSON_STRING | (JNODE_RAW<<8), k-j, &z[j]);
jsonParseAddNode(pParse, JSON_STRING, k-j, &z[j]);
pParse->hasNonstd = 1;
x = k;
}else{
@@ -3373,6 +3367,10 @@ static u32 jsonRenderBlob(
jsonAppendChar(pOut, '"');
break;
}
case JSONB_TEXTRAW: {
jsonAppendString(pOut, (const char*)&pParse->aBlob[i+n], sz);
break;
}
case JSONB_ARRAY: {
jsonAppendChar(pOut, '[');
j = i+n;
@@ -3481,10 +3479,14 @@ static int jsonParseValueFromBlob(JsonParse *pParse, u32 i){
jsonParseAddNode(pParse, JSON_REAL | (JNODE_JSON5<<8), sz, zPayload);
break;
}
case JSONB_TEXT: {
case JSONB_TEXTRAW: {
jsonParseAddNode(pParse, JSON_STRING | (JNODE_RAW<<8), sz, zPayload);
break;
}
case JSONB_TEXT: {
jsonParseAddNode(pParse, JSON_STRING, sz, zPayload);
break;
}
case JSONB_TEXTJ: {
jsonParseAddNode(pParse, JSON_STRING | (JNODE_ESCAPE<<8), sz, zPayload);
break;
@@ -3495,10 +3497,6 @@ static int jsonParseValueFromBlob(JsonParse *pParse, u32 i){
sz, zPayload);
break;
}
case JSONB_TEXTRAW: {
jsonParseAddNode(pParse, JSON_STRING | (JNODE_RAW<<8), sz, zPayload);
break;
}
case JSONB_ARRAY: {
int iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);
u32 j = i+x;
@@ -3529,6 +3527,10 @@ static int jsonParseValueFromBlob(JsonParse *pParse, u32 i){
if( k&1 ) return -1;
break;
}
default: {
pParse->nErr++;
break;
}
}
return i+x+sz;
}