]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: cli: some err/warn msg dumps add LR into CSV output on stat's CLI
authorEmeric Brun <ebrun@haproxy.com>
Tue, 23 Jan 2024 14:44:32 +0000 (15:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Jan 2024 07:38:59 +0000 (08:38 +0100)
commitef02dba7bcf4cf41aaf08fa5cabc8dd2d7537f63
tree7d5f05c9c467120fbe24d79463dd029b7ac4de50
parent5c88b9fcfb4a32b695c66b34fd36ceb10e0182f9
BUG/MEDIUM: cli: some err/warn msg dumps add LR into CSV output on stat's CLI

The initial purpose of CSV stats through CLI was to make it easely
parsable by scripts. But in some specific cases some error or warning
messages strings containing LF were dumped into cells of this CSV.

This made some parsing failure on several tools. In addition, if a
warning or message contains to successive LF, they will be dumped
directly but double LFs tag the end of the response on CLI and the
client may consider a truncated response.

This patch extends the 'csv_enc_append' and 'csv_enc' functions used
to format quoted string content according to RFC  with an additionnal
parameter to convert multi-lines strings to one line: CRs are skipped,
and LFs are replaced with spaces. In addition and optionally, it is
also possible to remove resulting trailing spaces.

The call of this function to fill strings into stat's CSV output is
updated to force this conversion.

This patch should be backported on all supported branches (issue was
already present in v2.0)
include/haproxy/tools.h
src/stats.c
src/tools.c