Skip to content

Fix parsing JSON array of string with comma#923

Merged
bazsi merged 2 commits intoaxoflow:mainfrom
MrAnno:fix-json-array-with-comma
Jan 22, 2026
Merged

Fix parsing JSON array of string with comma#923
bazsi merged 2 commits intoaxoflow:mainfrom
MrAnno:fix-json-array-with-comma

Conversation

@MrAnno
Copy link
Contributor

@MrAnno MrAnno commented Jan 22, 2026

Nice catch by @smortex

Cherry-picked from syslog-ng/syslog-ng#5604

smortex and others added 2 commits January 22, 2026 10:36
When a JSON array is parsed, a string value containing a comma and no
single or double quote is kept as-is and added to a list.  The comma
being a delimiter for list items, when the list is serialized to JSON
again, that comma is not treated as a part of the original string, but
as a separator:

```
["a", "b", "c,d"]    -> "a,b,c,d"
["a", "b", "c", "d"] <- "a,b,c,d"
```

Add the comma to the list of forbidden chars in a string to force
quoting of the value, preventing this bug:

```
["a", "b", "c,d"] -> "a,b,\"c,d\""
["a", "b", "c,d"] <- "a,b,\"c,d\""
```

Signed-off-by: Romain Tartière <[email protected]>
Signed-off-by: László Várady <[email protected]>
@MrAnno MrAnno requested a review from OverOrion January 22, 2026 09:39
@bazsi bazsi merged commit 76c8689 into axoflow:main Jan 22, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants