Hello community, here is the log from the commit of package perl-Text-CSV for openSUSE:Factory checked in at 2017-05-06 20:45:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Text-CSV (Old) and /work/SRC/openSUSE:Factory/.perl-Text-CSV.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "perl-Text-CSV" Sat May 6 20:45:30 2017 rev:20 rq:492406 version:1.95 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Text-CSV/perl-Text-CSV.changes 2017-04-20 20:47:36.876261201 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Text-CSV.new/perl-Text-CSV.changes 2017-05-06 20:45:31.837574249 +0200 @@ -1,0 +2,9 @@ +Thu Apr 27 06:53:44 UTC 2017 - coolo@suse.com + +- updated to 1.95 + see /usr/share/doc/packages/perl-Text-CSV/Changes + + 1.95 2017-04-27 + - import "strict" attribute introduced in Text::CSV_XS 1.29 + +------------------------------------------------------------------- Old: ---- Text-CSV-1.94.tar.gz New: ---- Text-CSV-1.95.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Text-CSV.spec ++++++ --- /var/tmp/diff_new_pack.sAs9rv/_old 2017-05-06 20:45:32.873428122 +0200 +++ /var/tmp/diff_new_pack.sAs9rv/_new 2017-05-06 20:45:32.881426994 +0200 @@ -17,7 +17,7 @@ Name: perl-Text-CSV -Version: 1.94 +Version: 1.95 Release: 0 %define cpan_name Text-CSV Summary: Comma-Separated Values Manipulator (Using Xs or Pureperl) ++++++ Text-CSV-1.94.tar.gz -> Text-CSV-1.95.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-1.94/Changes new/Text-CSV-1.95/Changes --- old/Text-CSV-1.94/Changes 2017-04-11 07:32:30.000000000 +0200 +++ new/Text-CSV-1.95/Changes 2017-04-26 19:38:44.000000000 +0200 @@ -1,5 +1,8 @@ Revision history for Perl extension Text::CSV. +1.95 2017-04-27 + - import "strict" attribute introduced in Text::CSV_XS 1.29 + 1.94 2017-04-11 - Fix 5.6.2 issues diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-1.94/META.json new/Text-CSV-1.95/META.json --- old/Text-CSV-1.94/META.json 2017-04-11 07:35:25.000000000 +0200 +++ new/Text-CSV-1.95/META.json 2017-04-26 19:40:08.000000000 +0200 @@ -47,5 +47,5 @@ "url" : "http://github.com/makamaka/Text-CSV" } }, - "version" : "1.94" + "version" : "1.95" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-1.94/META.yml new/Text-CSV-1.95/META.yml --- old/Text-CSV-1.94/META.yml 2017-04-11 07:35:25.000000000 +0200 +++ new/Text-CSV-1.95/META.yml 2017-04-26 19:40:08.000000000 +0200 @@ -25,4 +25,4 @@ Test::More: '0.71' resources: repository: http://github.com/makamaka/Text-CSV -version: '1.94' +version: '1.95' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-1.94/lib/Text/CSV.pm new/Text-CSV-1.95/lib/Text/CSV.pm --- old/Text-CSV-1.94/lib/Text/CSV.pm 2017-04-11 07:32:36.000000000 +0200 +++ new/Text-CSV-1.95/lib/Text/CSV.pm 2017-04-26 19:37:50.000000000 +0200 @@ -9,7 +9,7 @@ @EXPORT_OK = qw( csv ); BEGIN { - $VERSION = '1.94'; + $VERSION = '1.95'; $DEBUG = 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-1.94/lib/Text/CSV_PP.pm new/Text-CSV-1.95/lib/Text/CSV_PP.pm --- old/Text-CSV-1.94/lib/Text/CSV_PP.pm 2017-04-11 07:32:36.000000000 +0200 +++ new/Text-CSV-1.95/lib/Text/CSV_PP.pm 2017-04-26 19:37:50.000000000 +0200 @@ -12,7 +12,7 @@ use vars qw($VERSION @ISA @EXPORT_OK); use Carp; -$VERSION = '1.94'; +$VERSION = '1.95'; @ISA = qw(Exporter); @EXPORT_OK = qw(csv); @@ -57,6 +57,7 @@ 2011 => "ECR - Characters after end of quoted field", 2012 => "EOF - End of data in parsing input stream", 2013 => "ESP - Specification error for fragments RFC7111", + 2014 => "ENF - Inconsistent number of fields", # EIQ - Error Inside Quotes 2021 => "EIQ - NL char inside quotes, binary off", @@ -181,6 +182,7 @@ decode_utf8 => 1, auto_diag => 0, diag_verbose => 0, + strict => 0, blank_is_undef => 0, empty_is_undef => 0, allow_whitespace => 0, @@ -376,6 +378,7 @@ decode_utf8 => 35, _has_hooks => 36, _is_bound => 26, # 26 .. 29 + strict => 58, ); my %_hidden_cache_id = qw( @@ -546,6 +549,12 @@ $self->{binary}; } +sub strict { + my $self = shift; + @_ and $self->_set_attr_X ("strict", shift); + $self->{strict}; + } + sub decode_utf8 { my $self = shift; @_ and $self->_set_attr_X ("decode_utf8", shift); @@ -1463,7 +1472,7 @@ } for (qw/ - binary decode_utf8 always_quote quote_empty + binary decode_utf8 always_quote strict quote_empty allow_loose_quotes allow_loose_escapes allow_unquoted_escape allow_whitespace blank_is_undef empty_is_undef verbatim auto_diag diag_verbose @@ -1567,7 +1576,7 @@ for (qw/ binary decode_utf8 allow_loose_escapes allow_loose_quotes allow_whitespace always_quote quote_empty quote_space - escape_null quote_binary auto_diag diag_verbose + escape_null quote_binary auto_diag diag_verbose strict has_error_input blank_is_undef empty_is_undef has_ahead keep_meta_info verbatim has_hooks eol_is_cr eol_len /) { @@ -1782,6 +1791,15 @@ my $result = $self->____parse($ctx, $src, $fields, $fflags); $self->{_RECNO} = ++($ctx->{recno}); $self->{_EOF} = ''; + + if ($ctx->{strict}) { + $ctx->{strict_n} ||= $ctx->{fld_idx}; + if ($ctx->{strict_n} != $ctx->{fld_idx}) { + $self->__parse_error($ctx, 2014, $ctx->{used}); + return; + } + } + if ($ctx->{useIO}) { if (defined $ctx->{tmp} and $ctx->{used} < $ctx->{size} and $ctx->{has_ahead}) { $self->{_AHEAD} = substr($ctx->{tmp}, $ctx->{used}, $ctx->{size} - $ctx->{used}); @@ -2888,6 +2906,15 @@ simple string like C<"\x{00a0}"> might still be binary, but not marked UTF8, so setting C<< { binary => 1 } >> is still a wise option. +=head3 strict + + my $csv = Text::CSV_PP->new ({ strict => 1 }); + $csv->strict (0); + my $f = $csv->strict; + +If this attribute is set to C<1>, any row that parses to a different number +of fields than the previous row will cause the parser to throw error 2014. + =head3 decode_utf8 my $csv = Text::CSV_PP->new ({ decode_utf8 => 1 }); @@ -3709,7 +3736,8 @@ Note that in parsing with C<bind_columns>, the fields are set on the fly. That implies that if the third field of a row causes an error, the first two fields already have been assigned the values of the current row, while -the rest will still hold the values of the previous row. +the rest of the fields will still hold the values of the previous row. +If you want the parser to fail in these cases, use the L<C<strict>|/strict> attribute. =head2 eof @@ -4723,6 +4751,12 @@ Invalid specification for URI L</fragment> specification. =item * +2014 "ENF - Inconsistent number of fields" +X<2014> + +Inconsistent number of fields under strict parsing. + +=item * 2021 "EIQ - NL char inside quotes, binary off" X<2021> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-1.94/t/12_acc.t new/Text-CSV-1.95/t/12_acc.t --- old/Text-CSV-1.94/t/12_acc.t 2017-04-11 06:20:17.000000000 +0200 +++ new/Text-CSV-1.95/t/12_acc.t 2017-04-26 17:55:03.000000000 +0200 @@ -3,7 +3,7 @@ use strict; $^W = 1; # use warnings core since 5.6 -use Test::More tests => 194; +use Test::More tests => 196; BEGIN { $ENV{PERL_TEXT_CSV} = 0; @@ -32,6 +32,7 @@ is ($csv->auto_diag, 0, "auto_diag"); is ($csv->diag_verbose, 0, "diag_verbose"); is ($csv->verbatim, 0, "verbatim"); +is ($csv->strict, 0, "strict"); is ($csv->quote_space, 1, "quote_space"); is ($csv->quote_empty, 0, "quote_empty"); is ($csv->escape_null, 1, "escape_null"); @@ -84,6 +85,7 @@ is ($csv->diag_verbose (undef), 0, "diag_verbose (undef)"); is ($csv->diag_verbose (""), 0, "diag_verbose ("")"); is ($csv->verbatim (1), 1, "verbatim (1)"); +is ($csv->strict (1), 1, "strict (1)"); is ($csv->quote_space (1), 1, "quote_space (1)"); is ($csv->quote_empty (1), 1, "quote_empty (1)"); is ($csv->escape_null (1), 1, "escape_null (1)"); @@ -235,7 +237,7 @@ always_quote quote_space quote_empty quote_binary escape_null keep_meta_info - verbatim + verbatim strict types callbacks )]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-CSV-1.94/t/80_diag.t new/Text-CSV-1.95/t/80_diag.t --- old/Text-CSV-1.94/t/80_diag.t 2017-04-11 07:27:19.000000000 +0200 +++ new/Text-CSV-1.95/t/80_diag.t 2017-04-26 17:55:03.000000000 +0200 @@ -3,7 +3,7 @@ use strict; $^W = 1; - use Test::More tests => 278; + use Test::More tests => 286; #use Test::More "no_plan"; my %err; @@ -249,6 +249,18 @@ is (0 + $csv->error_diag, 1001, "Cannot set sep to current sep"); } +{ my $csv = Text::CSV->new ({ strict => 1 }); + ok ($csv->parse ("1,2,3"), "Set strict to 3 columns"); + ok ($csv->parse ("a,b,c"), "3 columns should be correct"); + is ($csv->parse ("3,4"), 0, "Not enough columns"); + is (0 + $csv->error_diag, 2014, "Error set correctly"); + } +{ my $csv = Text::CSV->new ({ strict => 1 }); + ok ($csv->parse ("1,2,3"), "Set strict to 3 columns"); + is ($csv->parse ("3,4,5,6"), 0, "Too many columns"); + is (0 + $csv->error_diag, 2014, "Error set correctly"); + } + { my $csv = Text::CSV->new; eval { $csv->header (undef, "foo"); }; is (0 + $csv->error_diag, 1014, "Cannot read header from undefined source");