fix 11940: quickCSV chokes on newlines in data
This commit is contained in:
parent
f2ac0bc67c
commit
4864a75340
2 changed files with 16 additions and 3 deletions
|
|
@ -679,7 +679,7 @@ sub quickCSV {
|
|||
my $params = shift;
|
||||
my ($sth, $output, @data);
|
||||
|
||||
my $csv = Text::CSV_XS->new({ eol => "\n" });
|
||||
my $csv = Text::CSV_XS->new({ eol => "\n", binary => 1 });
|
||||
|
||||
$sth = $self->prepare($sql);
|
||||
$sth->execute($params);
|
||||
|
|
@ -688,7 +688,10 @@ sub quickCSV {
|
|||
$output = $csv->string();
|
||||
|
||||
while (@data = $sth->array) {
|
||||
return undef unless $csv->combine(@data);
|
||||
if ( ! $csv->combine(@data) ) {
|
||||
$self->session->log->error( "Problem creating CSV row: " . $csv->error_diag );
|
||||
return undef;
|
||||
}
|
||||
$output .= $csv->string();
|
||||
}
|
||||
|
||||
|
|
|
|||
12
t/SQL.t
12
t/SQL.t
|
|
@ -17,7 +17,7 @@ use WebGUI::Session;
|
|||
use Data::Dumper;
|
||||
use Test::Deep;
|
||||
|
||||
use Test::More tests => 56; # increment this value for each test you create
|
||||
use Test::More tests => 57; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -299,3 +299,13 @@ cmp_deeply(
|
|||
'Check table structure',
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# REGRESSIONS
|
||||
|
||||
# 11940 : quickCSV chokes on newlines
|
||||
$session->db->write(
|
||||
'INSERT INTO testTable (myIndex,message,myKey) VALUES (?,?,?)',
|
||||
[ 10, "a\ntest", 'B' ],
|
||||
);
|
||||
ok( $session->db->quickCSV( 'SELECT * FROM testTable' ), 'get some output even with newlines in data' );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue