Skip to content

Commit

Permalink
util.c: bug fix: xsyslog_ev_escape_value learns to always quote the e…
Browse files Browse the repository at this point in the history
…mpty string

And regression test
  • Loading branch information
mjdominus committed Dec 24, 2024
1 parent 00a89e6 commit c4e782a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions cunit/util.testc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static void test_xsyslog_ev_escape_value(void)
"\r", "\"\\r\"",
"\r\n", "\"\\r\\n\"",
"-12.345e67", "-12.345e67",
"", "\"\"",
NULL,
};

Expand Down
1 change: 1 addition & 0 deletions lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,7 @@ static const char *xsyslog_ev_escape_value(struct buf *val)
const char *p;

escaped_len = orig_len = buf_len(val);
if (orig_len == 0) { return "\"\""; } // Make sure the empty string is visible

for (p = buf_cstring(val); *p; p++) {
switch (*p) {
Expand Down

0 comments on commit c4e782a

Please sign in to comment.