diff options
author | gregor herrmann <gregoa@debian.org> | 2024-01-07 22:23:24 +0100 |
---|---|---|
committer | gregor herrmann <gregoa@debian.org> | 2024-01-07 22:23:24 +0100 |
commit | c8b9686789e72911aaac4b5383ae8908cc086268 (patch) | |
tree | d8cb3dc314e95cbb46700a6812d58f0db1aa1453 | |
parent | 04bcfd755bfdeaef5b10ff00ac8109fb4d961566 (diff) | |
parent | 4ab3da176452af5c88ab65b1c794837ebfc1be10 (diff) |
New upstream version 0.89
-rw-r--r-- | Changes | 5 | ||||
-rw-r--r-- | META.json | 265 | ||||
-rw-r--r-- | META.yml | 10 | ||||
-rw-r--r-- | README | 2 | ||||
-rwxr-xr-x | Read.pm | 14 | ||||
-rw-r--r-- | cpanfile | 18 | ||||
-rwxr-xr-x | examples/ss-dups-tk.pl | 2 | ||||
-rwxr-xr-x | scripts/ss2tk | 2 | ||||
-rwxr-xr-x | scripts/xlscat | 28 | ||||
-rwxr-xr-x | scripts/xlsx2csv | 8 |
10 files changed, 196 insertions, 158 deletions
@@ -1,3 +1,8 @@ +0.89 - 02 Jan 2024, H.Merijn Brand + * Auto-use BOM in CSV *files* with xlscat script + * Fix duplicate option letter (typo) (Erix) + * It's 2024 + 0.88 - 07 Nov 2023, H.Merijn Brand * Guard $_ globbering from external bitrotted code * Use recommended and suggested versions based on known CVEs @@ -1,175 +1,178 @@ { - "release_status" : "stable", - "author" : [ - "H.Merijn Brand <perl5@tux.freedom.nl>" - ], - "generated_by" : "Author", - "dynamic_config" : 1, - "version" : "0.88", - "meta-spec" : { - "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", - "version" : 2 - }, - "abstract" : "Meta-Wrapper for reading spreadsheet data", - "provides" : { - "Spreadsheet::Read" : { - "version" : "0.88", - "file" : "Read.pm" - } - }, "name" : "Spreadsheet-Read", - "prereqs" : { - "test" : { - "recommends" : { - "Test::More" : "1.302196" - }, - "requires" : { - "Test::NoWarnings" : "0", - "Test::More" : "0.88", - "Test::Harness" : "0" - } - }, - "runtime" : { - "requires" : { - "List::Util" : "0", - "File::Temp" : "0.22", - "perl" : "5.008001", - "Data::Dumper" : "0", - "Encode" : "0", - "Carp" : "0", - "Exporter" : "0", - "Data::Peek" : "0" - }, - "recommends" : { - "IO::Scalar" : "0", - "Data::Peek" : "0.52", - "Encode" : "3.19", - "Data::Dumper" : "2.188", - "File::Temp" : "0.2311" - } - }, - "configure" : { - "requires" : { - "ExtUtils::MakeMaker" : "0" - }, - "suggests" : { - "ExtUtils::MakeMaker" : "7.70" - }, - "recommends" : { - "ExtUtils::MakeMaker" : "7.22" - } - } - }, - "resources" : { - "repository" : { - "url" : "https://github.com/Tux/Spreadsheet-Read", - "type" : "git", - "web" : "https://github.com/Tux/Spreadsheet-Read" - }, - "bugtracker" : { - "web" : "https://github.com/Tux/Spreadsheet-Read/issues" - }, - "license" : [ - "http://dev.perl.org/licenses/" - ] - }, "optional_features" : { - "opt_gnumeric" : { - "description" : "Provides parsing of Gnumeric spreadsheets", + "opt_ods" : { + "description" : "Provides parsing of OpenOffice spreadsheets", "prereqs" : { "runtime" : { - "requires" : { - "Spreadsheet::ReadGnumeric" : "0.2" - }, "recommends" : { - "Spreadsheet::ReadGnumeric" : "0.4" - } + "Spreadsheet::ParseODS" : "0.38" + }, + "requires" : { + "Spreadsheet::ParseODS" : "0.26" } } - }, - "opt_tools" : { + } + }, + "opt_xls" : { "prereqs" : { "runtime" : { "recommends" : { - "Tk::NoteBook" : "0", - "Tk::TableMatrix::Spreadsheet" : "0", - "Tk" : "804.036" - } - } - }, - "description" : "Spreadsheet tools" - }, - "opt_csv" : { - "description" : "Provides parsing of CSV streams", - "prereqs" : { - "runtime" : { + "Spreadsheet::ParseExcel" : "0.66" + }, "requires" : { - "Text::CSV_XS" : "0.71" - }, - "recommends" : { - "Text::CSV_XS" : "1.52", - "Text::CSV_PP" : "2.03", - "Text::CSV" : "2.03" - } + "Spreadsheet::ParseExcel::FmtDefault" : "0", + "Spreadsheet::ParseExcel" : "0.34" } } }, + "description" : "Provides parsing of Microsoft Excel files" + }, "opt_xlsx" : { - "description" : "Provides parsing of Microsoft Excel 2007 files", "prereqs" : { "runtime" : { + "recommends" : { + "Spreadsheet::ParseXLSX" : "0.29" + }, "requires" : { "Spreadsheet::ParseExcel::FmtDefault" : "0", "Spreadsheet::ParseXLSX" : "0.24" - }, - "recommends" : { - "Spreadsheet::ParseXLSX" : "0.27" - } } } }, - "opt_xls" : { + "description" : "Provides parsing of Microsoft Excel 2007 files" + }, + "opt_sxc" : { + "description" : "Provides parsing of OpenOffice spreadsheets old style", "prereqs" : { "runtime" : { + "recommends" : { + "Spreadsheet::ReadSXC" : "0.38" + }, "requires" : { - "Spreadsheet::ParseExcel::FmtDefault" : "0", - "Spreadsheet::ParseExcel" : "0.34" - }, + "Spreadsheet::ReadSXC" : "0.26" + } + } + } + }, + "opt_gnumeric" : { + "prereqs" : { + "runtime" : { + "requires" : { + "Spreadsheet::ReadGnumeric" : "0.2" + }, "recommends" : { - "Spreadsheet::ParseExcel" : "0.65" - } + "Spreadsheet::ReadGnumeric" : "0.4" } - }, - "description" : "Provides parsing of Microsoft Excel files" + } }, - "opt_ods" : { + "description" : "Provides parsing of Gnumeric spreadsheets" + }, + "opt_csv" : { "prereqs" : { "runtime" : { "recommends" : { - "Spreadsheet::ParseODS" : "0.38" - }, + "Text::CSV_PP" : "2.04", + "Text::CSV" : "2.04", + "Text::CSV_XS" : "1.53" + }, "requires" : { - "Spreadsheet::ParseODS" : "0.26" - } + "Text::CSV_XS" : "0.71" } - }, - "description" : "Provides parsing of OpenOffice spreadsheets" + } }, - "opt_sxc" : { + "description" : "Provides parsing of CSV streams" + }, + "opt_tools" : { + "description" : "Spreadsheet tools", "prereqs" : { "runtime" : { - "requires" : { - "Spreadsheet::ReadSXC" : "0.26" - }, "recommends" : { - "Spreadsheet::ReadSXC" : "0.38" - } + "Tk::NoteBook" : "0", + "Tk::TableMatrix::Spreadsheet" : "0", + "Tk" : "804.036" } - }, - "description" : "Provides parsing of OpenOffice spreadsheets old style" + } } + } + }, + "resources" : { + "bugtracker" : { + "web" : "https://github.com/Tux/Spreadsheet-Read/issues" }, + "license" : [ + "http://dev.perl.org/licenses/" + ], + "repository" : { + "web" : "https://github.com/Tux/Spreadsheet-Read", + "type" : "git", + "url" : "https://github.com/Tux/Spreadsheet-Read" + } + }, + "prereqs" : { + "runtime" : { + "suggests" : { + "Data::Dumper" : "2.188" + }, + "recommends" : { + "Data::Peek" : "0.52", + "Encode" : "3.20", + "Data::Dumper" : "2.183", + "File::Temp" : "0.2311", + "IO::Scalar" : "0" + }, + "requires" : { + "Data::Dumper" : "0", + "Exporter" : "0", + "File::Temp" : "0.22", + "Encode" : "0", + "perl" : "5.008001", + "Data::Peek" : "0", + "Carp" : "0", + "List::Util" : "0" + } + }, + "configure" : { + "recommends" : { + "ExtUtils::MakeMaker" : "7.22" + }, + "requires" : { + "ExtUtils::MakeMaker" : "0" + }, + "suggests" : { + "ExtUtils::MakeMaker" : "7.70" + } + }, + "test" : { + "requires" : { + "Test::NoWarnings" : "0", + "Test::Harness" : "0", + "Test::More" : "0.88" + }, + "recommends" : { + "Test::More" : "1.302198" + } + } + }, + "dynamic_config" : 1, + "abstract" : "Meta-Wrapper for reading spreadsheet data", "license" : [ "perl_5" - ] - } + ], + "provides" : { + "Spreadsheet::Read" : { + "file" : "Read.pm", + "version" : "0.89" + } + }, + "author" : [ + "H.Merijn Brand <perl5@tux.freedom.nl>" + ], + "release_status" : "stable", + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : 2 + }, + "version" : "0.89", + "generated_by" : "Author" +} @@ -43,14 +43,14 @@ optional_features: provides: Spreadsheet::Read: file: Read.pm - version: '0.88' + version: '0.89' recommends: - Data::Dumper: '2.188' + Data::Dumper: '2.183' Data::Peek: '0.52' - Encode: '3.19' + Encode: '3.20' File::Temp: '0.2311' IO::Scalar: 0 - Test::More: '1.302196' + Test::More: '1.302198' requires: Carp: 0 Data::Dumper: 0 @@ -67,4 +67,4 @@ resources: bugtracker: https://github.com/Tux/Spreadsheet-Read/issues license: http://dev.perl.org/licenses/ repository: https://github.com/Tux/Spreadsheet-Read -version: '0.88' +version: '0.89' @@ -73,7 +73,7 @@ H.Merijn Brand <perl5@tux.freedom.nl> =head1 COPYRIGHT AND LICENSE -Copyright (C) 2005-2023 H.Merijn Brand +Copyright (C) 2005-2024 H.Merijn Brand This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -38,7 +38,7 @@ use 5.008001; use strict; use warnings; -our $VERSION = "0.88"; +our $VERSION = "0.89"; sub Version { $VERSION } use Carp; @@ -2700,6 +2700,8 @@ L<Text::CSV_PP|https://metacpan.org/release/Text-CSV> (the pure perl version). L<Spreadsheet::ParseExcel|https://metacpan.org/release/Spreadsheet-ParseExcel> is the best parser for old-style Microsoft Excel (.xls) files. +Most recent commit was Dec 2023. Please use version 0.66 or higher to prevent +possible memory bombs. =item Spreadsheet::ParseXLSX @@ -2708,15 +2710,17 @@ like L<Spreadsheet::ParseExcel|https://metacpan.org/release/Spreadsheet-ParseExc but for new Microsoft Excel 2007+ files (.xlsx). They have the same API. This module uses L<XML::Twig|https://metacpan.org/release/XML-Twig> to parse the -internal XML. +internal XML. Most recent commit was in Dec 2023. Please use version 0.29 or +higher to prevent possible memory bombs. =item Spreadsheet::XLSX See L<Spreadsheet::XLSX|https://metacpan.org/release/Spreadsheet-XLSX> documentation. -This module is dead and deprecated. It is B<buggy and unmaintained>. I<Please> -use L<Spreadsheet::ParseXLSX|https://metacpan.org/release/Spreadsheet-ParseXLSX> +This module is dead and deprecated. It is B<buggy and unmaintained> (Most recent +commit was Oct 2014). I<Please> use +L<Spreadsheet::ParseXLSX|https://metacpan.org/release/Spreadsheet-ParseXLSX> instead. =item Excel::ValueReader::XLSX @@ -2784,7 +2788,7 @@ H.Merijn Brand <perl5@tux.freedom.nl> =head1 COPYRIGHT AND LICENSE -Copyright (C) 2005-2023 H.Merijn Brand +Copyright (C) 2005-2024 H.Merijn Brand This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -6,12 +6,14 @@ requires "Exporter"; requires "File::Temp" => "0.22"; # ignore : CVE-2011-4116 requires "List::Util"; -recommends "Data::Dumper" => "2.188"; +recommends "Data::Dumper" => "2.183"; recommends "Data::Peek" => "0.52"; -recommends "Encode" => "3.19"; +recommends "Encode" => "3.20"; recommends "File::Temp" => "0.2311"; recommends "IO::Scalar"; +suggests "Data::Dumper" => "2.188"; + on "configure" => sub { requires "ExtUtils::MakeMaker"; @@ -25,15 +27,15 @@ on "test" => sub { requires "Test::More" => "0.88"; requires "Test::NoWarnings"; - recommends "Test::More" => "1.302196"; + recommends "Test::More" => "1.302198"; }; feature "opt_csv", "Provides parsing of CSV streams" => sub { requires "Text::CSV_XS" => "0.71"; - recommends "Text::CSV" => "2.03"; - recommends "Text::CSV_PP" => "2.03"; - recommends "Text::CSV_XS" => "1.52"; + recommends "Text::CSV" => "2.04"; + recommends "Text::CSV_PP" => "2.04"; + recommends "Text::CSV_XS" => "1.53"; }; feature "opt_gnumeric", "Provides parsing of Gnumeric spreadsheets" => sub { @@ -64,12 +66,12 @@ feature "opt_xls", "Provides parsing of Microsoft Excel files" => sub { requires "Spreadsheet::ParseExcel" => "0.34"; requires "Spreadsheet::ParseExcel::FmtDefault"; - recommends "Spreadsheet::ParseExcel" => "0.65"; + recommends "Spreadsheet::ParseExcel" => "0.66"; }; feature "opt_xlsx", "Provides parsing of Microsoft Excel 2007 files" => sub { requires "Spreadsheet::ParseExcel::FmtDefault"; requires "Spreadsheet::ParseXLSX" => "0.24"; - recommends "Spreadsheet::ParseXLSX" => "0.27"; + recommends "Spreadsheet::ParseXLSX" => "0.29"; }; diff --git a/examples/ss-dups-tk.pl b/examples/ss-dups-tk.pl index f190f0a..bac15e5 100755 --- a/examples/ss-dups-tk.pl +++ b/examples/ss-dups-tk.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl # ss-dup-tk.pl: Find dups in spreadsheet -# (m)'18 [28-03-2018] Copyright H.M.Brand 2005-2023 +# (m)'18 [28-03-2018] Copyright H.M.Brand 2005-2024 use strict; use warnings; diff --git a/scripts/ss2tk b/scripts/ss2tk index 48a48e4..83a9c26 100755 --- a/scripts/ss2tk +++ b/scripts/ss2tk @@ -1,7 +1,7 @@ #!/usr/bin/perl # ss2tk: show SpreadSheet file in Tk::TableMatrix::Spreadsheet (*) -# (m)'22 [2022-01-31] Copyright H.M.Brand 2005-2023 +# (m)'22 [2022-01-31] Copyright H.M.Brand 2005-2024 use strict; use warnings; diff --git a/scripts/xlscat b/scripts/xlscat index 84a44dd..2616cf9 100755 --- a/scripts/xlscat +++ b/scripts/xlscat @@ -2,14 +2,14 @@ # xlscat: show supported spreadsheet file as Text # xlsgrep: grep pattern -# (m)'23 [2023-07-28] Copyright H.M.Brand 2005-2023 +# (m)'24 [2024-01-02] Copyright H.M.Brand 2005-2024 require 5.008001; use strict; use warnings; -our $VERSION = "3.25"; +our $VERSION = "3.27"; (my $CMD = $0) =~ s{.*[\/]}{}; my $is_grep = $0 =~ m/grep$/; # xlsgrep @@ -99,6 +99,7 @@ my $opt_d = 0; # Debug level for Spreadsheet::Read my $opt_h = 0; # Number of header lines for grep or -L my $opt_D = 0; # Dump: 0 = none, 1 = array, 2 = hash my $clip = 1; +my $enc_bom; # CSV input encoding derived from BOM my $enc_i; # Input encoding my $enc_o; # Output encoding GetOptions ( @@ -235,6 +236,28 @@ if (defined $file and $file ne "-") { $opt_v > 1 and warn "Using $file as input\n"; -f $file or usage 1, "the file argument is not a regular file"; -s $file or usage 1, "the file is empty"; + if ($file =~ m/\.csv$/i and open my $fh, "<", $file) { # Auto-BOM + my $l = <$fh>; + close $fh; + if ($l =~ s/^\x00\x00\xfe\xff//) { $enc_bom = "utf-32be" } + elsif ($l =~ s/^\xff\xfe\x00\x00//) { $enc_bom = "utf-32le" } + elsif ($l =~ s/^\xfe\xff//) { $enc_bom = "utf-16be" } + elsif ($l =~ s/^\xff\xfe//) { $enc_bom = "utf-16le" } + elsif ($l =~ s/^\xef\xbb\xbf//) { $enc_bom = "utf-8" } + elsif ($l =~ s/^\xf7\x64\x4c//) { $enc_bom = "utf-1" } + elsif ($l =~ s/^\xdd\x73\x66\x73//) { $enc_bom = "utf-ebcdic" } + elsif ($l =~ s/^\x0e\xfe\xff//) { $enc_bom = "scsu" } + elsif ($l =~ s/^\xfb\xee\x28//) { $enc_bom = "bocu-1" } + elsif ($l =~ s/^\x84\x31\x95\x33//) { $enc_bom = "gb-18030" } + elsif ($l =~ s/^\x{feff}//) { $enc_bom = "" } + + if ($enc_bom and open $fh, "<:encoding($enc_bom)", $file) { + $opt_v > 1 and warn "Opened $file with encoding $enc_bom after BOM detection\n"; + read $fh, (my $bom), 1; # Skip BOM + $file = $fh; + push @RDarg, parser => "CSV"; + } + } } else { $opt_v > 1 and warn "Working as a pipe\n"; @@ -477,6 +500,7 @@ foreach my $si (1 .. $sc) { ? "=".$s->{attr}[$_][$r]{formula} : defined $s->{cell}[$_][$r] ? $opt_u ? $uval : $fval : ""; } $c[0] .. $c[1]; + $r == 1 && $row[0] && defined $enc_bom and $row[0] =~ s/^\N{BOM}//; exists $print{col} and @row = @row[grep{$_<@row}@{$print{col}}]; $is_grep && $r > $opt_h && ! first { defined $_ && $_ =~ $pattern } @row and next; diff --git a/scripts/xlsx2csv b/scripts/xlsx2csv index 678e0f1..70d34d2 100755 --- a/scripts/xlsx2csv +++ b/scripts/xlsx2csv @@ -1,14 +1,14 @@ #!/usr/bin/perl # xls2csv: Convert supported spreadsheet formats to CSV -# (m)'23 [2023-06-26] Copyright H.M.Brand 2008-2023 +# (m)'23 [2023-12-04] Copyright H.M.Brand 2008-2024 require 5.008001; use strict; use warnings; -our $VERSION = "3.9"; +our $VERSION = "3.10"; (my $cmd = $0) =~ s{.*/}{}; use Text::CSV_XS; @@ -42,7 +42,7 @@ GetOptions ( "list" => sub { list_parsers (); }, "o|c|out=s" => \ my $csv, - "i|s|in=s" => \ my $xls, + "i|x|in=s" => \ my $xls, "f|force!" => \ my $opt_f, "s|sep=s" => \ my $opt_s, @@ -265,7 +265,7 @@ H.Merijn Brand <perl5@tux.freedom.nl> =head1 COPYRIGHT AND LICENSE -Copyright (C) 2008-2023 H.Merijn Brand +Copyright (C) 2008-2024 H.Merijn Brand This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |