Merge pull request #11318 from devwout/master

Fix visitParamExtractRaw for strings with unbalanced { or [.
This commit is contained in:
alexey-milovidov 2020-05-31 17:52:00 +03:00 committed by GitHub
commit 5b2b3739b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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');