Skip Menu |

This queue is for tickets about the Text-CSV CPAN distribution.

Report information
The Basics
Id: 109097
Status: resolved
Priority: 0/
Queue: Text-CSV

People
Owner: Nobody in particular
Requestors: kevin.broadey [...] ptti.co.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Text::CSV_PP mishandles double quotes when quote_char=undef
Date: Tue, 17 Nov 2015 22:18:55 +0000
To: "bug-Text-CSV [...] rt.cpan.org" <bug-Text-CSV [...] rt.cpan.org>
From: Kevin Broadey <kevin.broadey [...] ptti.co.uk>
#!/usr/bin/perl # # File: csvtest.pl # # Call with PERL_TEXT_CSV='Text::CSV_XS' or 'Text::CSV_PP' # to force the backend module. use strict; use warnings; use Text::CSV; print "backend = ", Text::CSV->backend, "\n"; my $csv = Text::CSV->new ( { quote_char=>undef } ) or die "Cannot use Text::CSV: ".Text::CSV->error_diag()."\n"; print "escape_char=<", ($csv->escape_char || 'undef'), ">\n"; $csv->print(\*STDOUT, [ 'space here', '"quoted"', '"quoted and spaces"' ]); --------------------------------------------------------------------------- $ PERL_TEXT_CSV='Text::CSV_PP' ./csvtest.pl backend = Text::CSV_PP escape_char=<"> space here,"quoted","quoted and spaces" --------------------------------------------------------------------------- $ PERL_TEXT_CSV='Text::CSV_XS' ./csvtest.pl backend = Text::CSV_XS escape_char=<"> space here,""quoted"",""quoted and spaces"" --------------------------------------------------------------------------- This is with Text::CSV 1.33 and Text::CSV_XS 1.20 and Perl 5.18. The behaviour with Text::CSV_XS seems consistent with the POD:- "If you change the default quote_char without changing the default escape_char, the escape_char will still be the quote mark.” Note that if I set escape_char to undef then I get the same behaviour (as exhibited by CSV_PP here) with CSV_XS too. -- Kevin Broadey
From: ozcoder [...] gmail.com
Hi Kevin, On Tue Nov 17 17:19:15 2015, kevin.broadey@ptti.co.uk wrote: Show quoted text
> #!/usr/bin/perl > # > # File: csvtest.pl > # > # Call with PERL_TEXT_CSV='Text::CSV_XS' or 'Text::CSV_PP' > # to force the backend module. > > use strict; > use warnings; > > use Text::CSV; > > print "backend = ", Text::CSV->backend, "\n"; > > my $csv = Text::CSV->new ( { quote_char=>undef } ) > or die "Cannot use Text::CSV: ".Text::CSV->error_diag()."\n"; > > print "escape_char=<", ($csv->escape_char || 'undef'), ">\n"; > > $csv->print(\*STDOUT, [ 'space here', '"quoted"', '"quoted and > spaces"' ]); > > --------------------------------------------------------------------------- > > > $ PERL_TEXT_CSV='Text::CSV_PP' ./csvtest.pl > backend = Text::CSV_PP > escape_char=<"> > space here,"quoted","quoted and spaces" > > --------------------------------------------------------------------------- > > $ PERL_TEXT_CSV='Text::CSV_XS' ./csvtest.pl > backend = Text::CSV_XS > escape_char=<"> > space here,""quoted"",""quoted and spaces"" > > > --------------------------------------------------------------------------- > > This is with Text::CSV 1.33 and Text::CSV_XS 1.20 and Perl 5.18. > > The behaviour with Text::CSV_XS seems consistent with the POD:- > > "If you change the default quote_char without changing the default > escape_char, the escape_char will still be the quote mark.” > > > Note that if I set escape_char to undef then I get the same behaviour > (as exhibited by CSV_PP here) with CSV_XS too. > > -- > Kevin Broadey > > > > > > > >
I have fixed this issue. See my commit https://github.com/ozcoder/Text-CSV/commit/c0df764045340ece0dad620ca7237f19be355e44 Gordon
On Fri Feb 12 12:11:30 2016, ozcoder@gmail.com wrote: Show quoted text
> Hi Kevin, > > On Tue Nov 17 17:19:15 2015, kevin.broadey@ptti.co.uk wrote:
> > #!/usr/bin/perl > > # > > # File: csvtest.pl > > # > > # Call with PERL_TEXT_CSV='Text::CSV_XS' or 'Text::CSV_PP' > > # to force the backend module. > > > > use strict; > > use warnings; > > > > use Text::CSV; > > > > print "backend = ", Text::CSV->backend, "\n"; > > > > my $csv = Text::CSV->new ( { quote_char=>undef } ) > > or die "Cannot use Text::CSV: ".Text::CSV->error_diag()."\n"; > > > > print "escape_char=<", ($csv->escape_char || 'undef'), ">\n"; > > > > $csv->print(\*STDOUT, [ 'space here', '"quoted"', '"quoted and > > spaces"' ]); > > > > --------------------------------------------------------------------------- > > > > > > $ PERL_TEXT_CSV='Text::CSV_PP' ./csvtest.pl > > backend = Text::CSV_PP > > escape_char=<"> > > space here,"quoted","quoted and spaces" > > > > --------------------------------------------------------------------------- > > > > $ PERL_TEXT_CSV='Text::CSV_XS' ./csvtest.pl > > backend = Text::CSV_XS > > escape_char=<"> > > space here,""quoted"",""quoted and spaces"" > > > > > > --------------------------------------------------------------------------- > > > > This is with Text::CSV 1.33 and Text::CSV_XS 1.20 and Perl 5.18. > > > > The behaviour with Text::CSV_XS seems consistent with the POD:- > > > > "If you change the default quote_char without changing the default > > escape_char, the escape_char will still be the quote mark.” > > > > > > Note that if I set escape_char to undef then I get the same behaviour > > (as exhibited by CSV_PP here) with CSV_XS too. > > > > -- > > Kevin Broadey > > > > > > > > > > > > > > > >
> > I have fixed this issue. See my commit > https://github.com/ozcoder/Text- > CSV/commit/c0df764045340ece0dad620ca7237f19be355e44 > > Gordon
Thanks. Applied: https://github.com/makamaka/Text-CSV/commit/5a2da66c9d60b5ae8013236da87c072158500984
On Fri Jan 20 15:18:28 2017, ISHIGAKI wrote: Show quoted text
> On Fri Feb 12 12:11:30 2016, ozcoder@gmail.com wrote:
> > Hi Kevin, > > > > On Tue Nov 17 17:19:15 2015, kevin.broadey@ptti.co.uk wrote:
> > > #!/usr/bin/perl > > > # > > > # File: csvtest.pl > > > # > > > # Call with PERL_TEXT_CSV='Text::CSV_XS' or 'Text::CSV_PP' > > > # to force the backend module. > > > > > > use strict; > > > use warnings; > > > > > > use Text::CSV; > > > > > > print "backend = ", Text::CSV->backend, "\n"; > > > > > > my $csv = Text::CSV->new ( { quote_char=>undef } ) > > > or die "Cannot use Text::CSV: ".Text::CSV->error_diag()."\n"; > > > > > > print "escape_char=<", ($csv->escape_char || 'undef'), ">\n"; > > > > > > $csv->print(\*STDOUT, [ 'space here', '"quoted"', '"quoted and > > > spaces"' ]); > > > > > > --------------------------------------------------------------------------- > > > > > > > > > $ PERL_TEXT_CSV='Text::CSV_PP' ./csvtest.pl > > > backend = Text::CSV_PP > > > escape_char=<"> > > > space here,"quoted","quoted and spaces" > > > > > > --------------------------------------------------------------------------- > > > > > > $ PERL_TEXT_CSV='Text::CSV_XS' ./csvtest.pl > > > backend = Text::CSV_XS > > > escape_char=<"> > > > space here,""quoted"",""quoted and spaces"" > > > > > > > > > --------------------------------------------------------------------------- > > > > > > This is with Text::CSV 1.33 and Text::CSV_XS 1.20 and Perl 5.18. > > > > > > The behaviour with Text::CSV_XS seems consistent with the POD:- > > > > > > "If you change the default quote_char without changing the default > > > escape_char, the escape_char will still be the quote mark.” > > > > > > > > > Note that if I set escape_char to undef then I get the same > > > behaviour > > > (as exhibited by CSV_PP here) with CSV_XS too. > > > > > > -- > > > Kevin Broadey > > > > > > > > > > > > > > > > > > > > > > > >
> > > > I have fixed this issue. See my commit > > https://github.com/ozcoder/Text- > > CSV/commit/c0df764045340ece0dad620ca7237f19be355e44 > > > > Gordon
> > > Thanks. Applied: https://github.com/makamaka/Text- > CSV/commit/5a2da66c9d60b5ae8013236da87c072158500984
Closed as 1.91 is out. Thanks.