From 55b7d96075df1e88fa8d525158247634abe9d180 Mon Sep 17 00:00:00 2001 From: Darold Gilles Date: Tue, 30 Sep 2014 21:04:30 +0200 Subject: [PATCH] Enable allow_loose_quotes and undef escape_char in Text::CSV_XS call to fix CSV format error when fields have quote inside an unquoted field. Thanks to Josh Berkus for the report. --- pgbadger | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pgbadger b/pgbadger index fc2d7ae..6c35908 100755 --- a/pgbadger +++ b/pgbadger @@ -1932,7 +1932,15 @@ sub process_file if ($format eq 'csv') { require Text::CSV_XS; - my $csv = Text::CSV_XS->new({binary => 1, eol => $/, sep_char => $csv_sep_char}); + my $csv = Text::CSV_XS->new( + { + binary => 1, + eol => $/, + sep_char => $csv_sep_char, + allow_loose_quotes => 1, + escape_char => undef + } + ); # Parse csvlog lines while (my $row = $csv->getline($lfile)) { @@ -2019,7 +2027,7 @@ sub process_file } } if (!$getout) { - $csv->eof or warn "FATAL: cannot use CSV, " . $csv->error_diag() . "\n"; + $csv->eof or warn "FATAL: cannot use CSV on $logfile, " . $csv->error_diag() . "\n"; } } -- 2.40.0