Fix visitParamExtractRaw for strings with unbalanced { or [.

Closes #11254 .
This commit is contained in:
Ewout 2020-05-30 21:44:22 +02:00
parent a4b2daae0d
commit 70eaae38f2
3 changed files with 12 additions and 5 deletions

View File

@ -22,6 +22,14 @@ struct ExtractRaw
expects_end.pop_back();
current_expect_end = expects_end.empty() ? 0 : expects_end.back();
}
else if (current_expect_end == '"')
{
/// skip backslash
if (*pos == '\\' && pos + 1 < end && pos[1] == '"')
{
pos++;
}
}
else
{
switch (*pos)
@ -38,11 +46,6 @@ struct ExtractRaw
current_expect_end = '"';
expects_end.push_back(current_expect_end);
break;
case '\\':
/// skip backslash
if (pos + 1 < end && pos[1] == '"')
pos++;
break;
default:
if (!current_expect_end && (*pos == ',' || *pos == '}'))
{

View File

@ -9,5 +9,7 @@ test"string
"test_string"
"test\\"string"
"test\\"string"
"{"
"["
["]", "2", "3"]
{"nested" : [1,2,3]}

View File

@ -11,5 +11,7 @@ SELECT visitParamExtractRaw('{"myparam":"test_string"}', 'myparam');
SELECT visitParamExtractRaw('{"myparam": "test_string"}', 'myparam');
SELECT visitParamExtractRaw('{"myparam": "test\\"string"}', 'myparam');
SELECT visitParamExtractRaw('{"myparam": "test\\"string", "other":123}', 'myparam');
SELECT visitParamExtractRaw('{"myparam": "{"}', 'myparam');
SELECT visitParamExtractRaw('{"myparam": "["}', 'myparam');
SELECT visitParamExtractRaw('{"myparam": ["]", "2", "3"], "other":123}', 'myparam');
SELECT visitParamExtractRaw('{"myparam": {"nested" : [1,2,3]}, "other":123}', 'myparam');