Verified Commit 6a219092 authored by eater  's avatar eater

spa: escape double quotes

parent 63a3811a
Pipeline #272837 passed with stages
in 59 seconds
......@@ -346,6 +346,9 @@ static inline int spa_json_encode_string(char *str, int size, const char *val)
case '\f':
__PUT('\\'); __PUT('f');
break;
case '"':
__PUT('\\'); __PUT('"');
break;
default:
__PUT(*val);
break;
......
......@@ -160,8 +160,8 @@ static void test_encode(void)
spa_assert(strncmp(dst4, "\"tes", 4) == 0);
spa_assert(spa_json_encode_string(dst6, sizeof(dst6), "test") == 6);
spa_assert(strncmp(dst6, "\"test\"", 6) == 0);
spa_assert(spa_json_encode_string(dst, sizeof(dst), "test\"\n\r \t\b\f\'") == 19);
spa_assert(strcmp(dst, "\"test\"\\n\\r \\t\\b\\f'\"") == 0);
spa_assert(spa_json_encode_string(dst, sizeof(dst), "test\"\n\r \t\b\f\'") == 20);
spa_assert(strcmp(dst, "\"test\\\"\\n\\r \\t\\b\\f'\"") == 0);
}
int main(int argc, char *argv[])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment