From gowen@swynwyr.com Mon Oct 14 10: | 07:21 2013 |
MIME-Version: | 1.0 |
X-Spam-Status: | No, score=-6.89 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, T_HDRS_LCASE=0.01] autolearn=ham |
X-Spam-Flag: | NO |
Message-ID: | <3a1cd56b58d7af5667a3360fa0e9bc83@www.swynwyr.com> |
content-type: | text/plain; charset="utf-8"; format="fixed" |
X-Virus-Scanned: | Debian amavisd-new at bestpractical.com |
X-Spam-Score: | -6.89 |
Received: | from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B62FB61E003 for <cpan-bug+Spreadsheet-XLSX@hipster.bestpractical.com>; Mon, 14 Oct 2013 10:07:21 -0400 (EDT) |
Received: | from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wOeOg+Z7-uPo for <cpan-bug+Spreadsheet-XLSX@hipster.bestpractical.com>; Mon, 14 Oct 2013 10:07:20 -0400 (EDT) |
Received: | from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 100652400EB for <bug-Spreadsheet-XLSX@rt.cpan.org>; Mon, 14 Oct 2013 10:07:19 -0400 (EDT) |
Received: | (qmail 23100 invoked by alias); 14 Oct 2013 14:07:19 -0000 |
Received: | from bifrost.swynwyr.com (HELO li5-92.members.linode.com) (65.19.178.92) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Mon, 14 Oct 2013 07:07:13 -0700 |
Received: | from www.swynwyr.com (bifrost.swynwyr.com [65.19.178.92]) by li5-92.members.linode.com (Postfix) with ESMTPSA id E73764AEE for <bug-Spreadsheet-XLSX@rt.cpan.org>; Mon, 14 Oct 2013 10:07:08 -0400 (EDT) |
Delivered-To: | cpan-bug+Spreadsheet-XLSX@hipster.bestpractical.com |
Subject: | Uninitialized $row, $col can be minimized by cautious default |
Return-Path: | <gowen@swynwyr.com> |
X-RT-Mail-Extension: | spreadsheet-xlsx |
X-Original-To: | cpan-bug+Spreadsheet-XLSX@hipster.bestpractical.com |
X-Spam-Check-BY: | la.mx.develooper.com |
Date: | Mon, 14 Oct 2013 10:07:08 -0400 |
X-Spam-Level: | |
To: | <bug-Spreadsheet-XLSX@rt.cpan.org> |
Content-Transfer-Encoding: | 8bit |
From: | "Greg Owen" <gowen@swynwyr.com> |
X-RT-Original-Encoding: | utf-8 |
X-RT-Interface: | |
Content-Length: | 2280 |
In some cases, $row and $col are not being set for a worksheet. As a result,
when Spreadsheet::XLSX is parsing the worksheet, it spews warnings as follows
(over and over and over and...):
Use of uninitialized value $row in numeric lt (<) at
/usr/local/share/perl5/Spreadsheet/XLSX.pm line 194.
Use of uninitialized value $col in numeric lt (<) at
/usr/local/share/perl5/Spreadsheet/XLSX.pm line 195.
Use of uninitialized value $row in numeric gt (>) at
/usr/local/share/perl5/Spreadsheet/XLSX.pm line 196.
Use of uninitialized value in numeric gt (>) at
/usr/local/share/perl5/Spreadsheet/XLSX.pm line 196.
Use of uninitialized value $col in numeric gt (>) at
/usr/local/share/perl5/Spreadsheet/XLSX.pm line 197.
Use of uninitialized value in numeric gt (>) at
/usr/local/share/perl5/Spreadsheet/XLSX.pm line 197.
Use of uninitialized value $row in array element at
/usr/local/share/perl5/Spreadsheet/XLSX.pm line 214.
Use of uninitialized value $col in array element at
/usr/local/share/perl5/Spreadsheet/XLSX.pm line 214.
I have not yet determined why this worksheet can't be parsed - I suspect it's
because the worksheet has little to no native content and consists entirely of
formulas referencing data on another worksheet.
In any case, the error spew can be resolved by setting $row and $col to an
initial value of 0. It seems a proper bit of defensive programming to assume a
worksheet has dimensions 0x0 until proven otherwise by getting a correct
setting. If, as is the case that I'm experiencing, it never gets that proper
setting, at least it won't spew messages ad infinitum.
I propose the following change to minimize disruption by unfriendly worksheets:
% diff -c XLSX.pm.orig XLSX.pm
*** XLSX.pm.orig 2013-10-14 09:32:05.081273321 -0400
--- XLSX.pm 2013-10-14 10:02:20.118579289 -0400
***************
*** 149,155 ****
my $member_sheet = $self -> {zip} -> memberNamed
("xl/$sheet->{path}") or next;
! my ($row, $col);
my $flag = 0;
my $s = 0;
--- 149,156 ----
my $member_sheet = $self -> {zip} -> memberNamed
("xl/$sheet->{path}") or next;
! my $row = 0;
! my $col = 0;
my $flag = 0;
my $s = 0;