From 9350f2c2510bb63b07e01bbccfca8e7de4e3ce63 Mon Sep 17 00:00:00 2001 From: cpq Date: Tue, 9 Jun 2026 12:25:25 +0100 Subject: [PATCH] dash nit --- mongoose.c | 5 ++++- src/dash.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index 7ac58a0e..64b55af7 100644 --- a/mongoose.c +++ b/mongoose.c @@ -883,7 +883,10 @@ static int mg_dash_parse_field(struct mg_str json, struct mg_field *f) { ok = f->value_size == sizeof(double) && mg_json_get_num(json, json_path, (double *) f->value); } else if (f->type == MG_VAL_STR && f->value_size > 0) { - ok = mg_json_unescape(json, json_path, (char *) f->value, f->value_size); + struct mg_str tok = mg_json_get_tok(json, json_path); + ok = tok.len >= 2 && tok.buf[0] == '"' && + tok.buf[tok.len - 1] == '"'; + if (ok) mg_json_unescape(json, json_path, (char *) f->value, f->value_size); } else if (f->type == MG_VAL_RAW && f->value_size > 0) { ok = mg_snprintf((char *) f->value, f->value_size, "%.*s", json.len, json.buf) == json.len; diff --git a/src/dash.c b/src/dash.c index 58f21609..f3486c2d 100644 --- a/src/dash.c +++ b/src/dash.c @@ -224,7 +224,10 @@ static int mg_dash_parse_field(struct mg_str json, struct mg_field *f) { ok = f->value_size == sizeof(double) && mg_json_get_num(json, json_path, (double *) f->value); } else if (f->type == MG_VAL_STR && f->value_size > 0) { - ok = mg_json_unescape(json, json_path, (char *) f->value, f->value_size); + struct mg_str tok = mg_json_get_tok(json, json_path); + ok = tok.len >= 2 && tok.buf[0] == '"' && + tok.buf[tok.len - 1] == '"'; + if (ok) mg_json_unescape(json, json_path, (char *) f->value, f->value_size); } else if (f->type == MG_VAL_RAW && f->value_size > 0) { ok = mg_snprintf((char *) f->value, f->value_size, "%.*s", json.len, json.buf) == json.len;