Skip to content

Commit 447d540

Browse files
committed
in_tail: detect, skip UTF-8 BOM
If unicode input data is not converted, check if there is a UTF-8 BOM present and skip it. Signed-off-by: Erik Cederberg <[email protected]>
1 parent f6d036e commit 447d540

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

plugins/in_tail/tail_file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,14 @@ static int process_content(struct flb_tail_file *file, size_t *bytes)
471471
}
472472
else if (ret == FLB_UNICODE_CONVERT_NOP) {
473473
flb_plg_debug(ctx->ins, "nothing to convert encoding '%.*s'", end - data, data);
474+
/* Skip the UTF-8 BOM */
475+
if (file->buf_len >= 3 &&
476+
data[0] == '\xEF' &&
477+
data[1] == '\xBB' &&
478+
data[2] == '\xBF') {
479+
data += 3;
480+
processed_bytes += 3;
481+
}
474482
}
475483
else {
476484
flb_plg_error(ctx->ins, "encoding failed '%.*s'", end - data, data);

0 commit comments

Comments
 (0)