From 04ade0a92b82db252613de735fcfc74c4c96610d Mon Sep 17 00:00:00 2001 From: SummerSolsticeMuch Date: Fri, 3 Apr 2026 16:20:44 +0800 Subject: [PATCH] fix: handle \\ escape sequence in minify_string() minify_string() only handled \" as an in-string escape but not \\. The sequence \\" (escaped backslash followed by closing quote) was misinterpreted as an escaped quote, causing the minifier to read past the actual string boundary and include trailing data in the output. Add \\ handling before the \" check so that escaped backslashes are consumed correctly and the real closing quote is recognized. --- cJSON.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cJSON.c b/cJSON.c index 88c2d95b..73c8a1ce 100644 --- a/cJSON.c +++ b/cJSON.c @@ -2913,6 +2913,10 @@ static void minify_string(char **input, char **output) { *input += static_strlen("\""); *output += static_strlen("\""); return; + } else if (((*input)[0] == '\\') && ((*input)[1] == '\\')) { + (*output)[1] = (*input)[1]; + *input += static_strlen("\\"); + *output += static_strlen("\\"); } else if (((*input)[0] == '\\') && ((*input)[1] == '\"')) { (*output)[1] = (*input)[1]; *input += static_strlen("\"");