Skip to content

Commit 80776bf

Browse files
committed
multiline: rule: append \n if missing
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 5bd3211 commit 80776bf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/multiline/flb_ml_rule.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ int flb_ml_rule_process(struct flb_ml_parser *ml_parser,
267267
msgpack_object *val_pattern)
268268
{
269269
int ret;
270+
int len;
270271
char *buf_data = NULL;
271272
size_t buf_size = 0;
272273
struct mk_list *head;
@@ -330,7 +331,18 @@ int flb_ml_rule_process(struct flb_ml_parser *ml_parser,
330331
(unsigned char *) buf_data, buf_size);
331332
if (ret) {
332333
/* Regex matched */
333-
flb_sds_cat_safe(&group->buf, buf_data, buf_size);
334+
335+
len = flb_sds_len(group->buf);
336+
if (len >= 1 && group->buf[len - 1] != '\n') {
337+
flb_sds_cat_safe(&group->buf, "\n", 1);
338+
}
339+
340+
if (buf_size == 0) {
341+
flb_sds_cat_safe(&group->buf, "\n", 1);
342+
}
343+
else {
344+
flb_sds_cat_safe(&group->buf, buf_data, buf_size);
345+
}
334346
rule = st->rule;
335347
break;
336348
}

0 commit comments

Comments
 (0)