From: Olivier Houchard Date: Wed, 25 Nov 2026 15:28:48 +0000 (+0100) Subject: BUG/MEDIUM: mjson: decode the escaped slash in strings X-Git-Tag: v3.5-dev14~21 X-Git-Url: https://git.kaiwu.me/http/ngx_http_ssi_module.html?a=commitdiff_plain;h=1bc8a562302acdf5cfdb1949b529c319fd7b931c;p=haproxy.git BUG/MEDIUM: mjson: decode the escaped slash in strings RFC 8259 allows the slash to be escaped in JSON strings as "\/", and some encoders emit it by default (e.g. PHP's json_encode()). But mjson_unescape() does not know this escape and fails, so no value is returned for such strings by json_query(), jwt_header_query() and jwt_payload_query(), nor to the ACME client which extracts strings the same way. This can be reproduced with req.body,json_query('$.url') on {"url":"\/a\/b"}. Let's add the slash to the escapes known by mjson_esc(). This exists since the library was imported in 2.4-dev17 by commit 41007a683 ("MINOR: sample: converter: Add mjson library."). It must be backported to all supported versions. --- diff --git a/src/mjson.c b/src/mjson.c index c8dc61738..a60386dd1 100644 --- a/src/mjson.c +++ b/src/mjson.c @@ -27,7 +27,7 @@ static double mystrtod(const char *str, int len, char **end); static int mjson_esc(int c, int esc) { - const char *p, *esc1 = "\b\f\n\r\t\\\"", *esc2 = "bfnrt\\\""; + const char *p, *esc1 = "\b\f\n\r\t\\\"/", *esc2 = "bfnrt\\\"/"; for (p = esc ? esc1 : esc2; *p != '\0'; p++) { if (*p == c) return esc ? esc2[p - esc1] : esc1[p - esc2]; }