diff --git a/spa/include/spa/utils/json.h b/spa/include/spa/utils/json.h index c1c324e03..5fd436994 100644 --- a/spa/include/spa/utils/json.h +++ b/spa/include/spa/utils/json.h @@ -166,7 +166,7 @@ static inline int spa_json_next(struct spa_json * iter, const char **value) } if (iter->depth != 0) return -1; - if (iter->state == __BARE) { + if (iter->state != __STRUCT) { iter->state = __STRUCT; return iter->cur - *value; } @@ -290,7 +290,7 @@ static inline int spa_json_parse_string(const char *val, int len, char *result) result[len] = '\0'; return 1; } - for (p = val+1; p < val + len-1; p++) { + for (p = val+1; p < val + len; p++) { if (*p == '\\') { p++; if (*p == 'n') @@ -305,6 +305,8 @@ static inline int spa_json_parse_string(const char *val, int len, char *result) *result++ = '\f'; else *result++ = *p; + } else if (*p == '\"') { + break; } else *result++ = *p; } diff --git a/src/tests/test-properties.c b/src/tests/test-properties.c index 2ad026166..e00858308 100644 --- a/src/tests/test-properties.c +++ b/src/tests/test-properties.c @@ -232,6 +232,16 @@ static void test_new_string(void) spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz")); pw_properties_free(props); + + props = pw_properties_new_string("foo=bar bar=\"baz"); + spa_assert(props != NULL); + spa_assert(props->flags == 0); + spa_assert(props->dict.n_items == 2); + + spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar")); + spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz")); + + pw_properties_free(props); } static void test_update(void)