mirror of
https://github.com/cesanta/mongoose.git
synced 2026-12-04 21:58:22 +00:00
Merge pull request #1642 from cesanta/fix-json
Fix json's MG_EOO in nested objects
This commit is contained in:
3 files changed
+3
-3
No files matched your search
+1
-1
@@ -2496,7 +2496,7 @@ int mg_json_get(const char *s, int len, const char *path, int *toklen) {
|
|||||||
// Ditto for `{` and `}`. Hence +2 in the code below.
|
// Ditto for `{` and `}`. Hence +2 in the code below.
|
||||||
#define MG_EOO(x) \
|
#define MG_EOO(x) \
|
||||||
do { \
|
do { \
|
||||||
if (depth == ed && ci != ei) return MG_JSON_NOT_FOUND; \
|
if (depth == ed && (ci != ei || ci < 0)) return MG_JSON_NOT_FOUND; \
|
||||||
if (c != nesting[depth - 1] + 2) return MG_JSON_INVALID; \
|
if (c != nesting[depth - 1] + 2) return MG_JSON_INVALID; \
|
||||||
depth--; \
|
depth--; \
|
||||||
MG_CHECKRET(x); \
|
MG_CHECKRET(x); \
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ int mg_json_get(const char *s, int len, const char *path, int *toklen) {
|
|||||||
// Ditto for `{` and `}`. Hence +2 in the code below.
|
// Ditto for `{` and `}`. Hence +2 in the code below.
|
||||||
#define MG_EOO(x) \
|
#define MG_EOO(x) \
|
||||||
do { \
|
do { \
|
||||||
if (depth == ed && ci != ei) return MG_JSON_NOT_FOUND; \
|
if (depth == ed && (ci != ei || ci < 0)) return MG_JSON_NOT_FOUND; \
|
||||||
if (c != nesting[depth - 1] + 2) return MG_JSON_INVALID; \
|
if (c != nesting[depth - 1] + 2) return MG_JSON_INVALID; \
|
||||||
depth--; \
|
depth--; \
|
||||||
MG_CHECKRET(x); \
|
MG_CHECKRET(x); \
|
||||||
|
|||||||
+1
-1
@@ -2317,7 +2317,7 @@ static void test_get_header_var(void) {
|
|||||||
static void test_json(void) {
|
static void test_json(void) {
|
||||||
const char *s;
|
const char *s;
|
||||||
const char *s1 = "{\"a\":{},\"b\":7,\"c\":[[],2]}";
|
const char *s1 = "{\"a\":{},\"b\":7,\"c\":[[],2]}";
|
||||||
const char *s2 = "{\"a\":{\"b1\":{}},\"c\":7}";
|
const char *s2 = "{\"a\":{\"b1\":{}},\"c\":7,\"d\":{\"b2\":{}}}";
|
||||||
int n, n1 = (int) strlen(s1), n2 = (int) strlen(s2);
|
int n, n1 = (int) strlen(s1), n2 = (int) strlen(s2);
|
||||||
|
|
||||||
ASSERT(mg_json_get(" true ", 6, "", &n) == MG_JSON_INVALID);
|
ASSERT(mg_json_get(" true ", 6, "", &n) == MG_JSON_INVALID);
|
||||||
|
|||||||
Reference in new issue
Block a user