Skip Menu |
 

This queue is for tickets about the Config-Auto CPAN distribution.

Report information
The Basics
Id: 74711
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Config-Auto

People
Owner: BINGOS [...] cpan.org
Requestors: davido [...] cpan.org
Cc: dllaurence [...] dslextreme.com
AdminCc:

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



CC: dllaurence [...] dslextreme.com
Subject: Calling Config::Auto::parse while $_ aliases a constant value throws exception.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1328487174-1148-10"
Content-Length: 0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 523
Download (untitled) / with headers
text/plain 523b
Reported on the uuasc@uuasc.org mailing list (Unix Users Association of Southern California) by Dustin Laurence. If $_ is aliased to a constant such as a string literal prior to calling Config::Auto::parse(), an exception will be thrown complaining about attempting to modify a readonly value. Dustin Laurence created a snippet of sample code that will cause Config::Auto to throw, and I pared it down further and turned it into a proper test. The test script that will cause an exception to be thrown is attached. Dave
Subject: constalias_it.pl
MIME-Version: 1.0
Content-Type: application/octet-stream; name="constalias_it.pl"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="constalias_it.pl"
Content-Transfer-Encoding: base64
Content-Length: 442
Download constalias_it.pl
text/x-perl 442b
#!perl use Test::More; use Test::Exception; use strict; use Config::Auto; my $test_file = "/etc/fstab"; # A file found on any Unix/Linux machine. SKIP: { skip "Can't test: $test_file doesn't exist on this system." unless -e $test_file; for ( 'bar' ) { lives_ok{ Config::Auto::parse($test_file) } 'Config::Auto:parse() where $_ aliases a string literal.'; } } done_testing();
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1328500314-17369-139"
Message-ID: <rt-3.8.HEAD-17369-1328500314-87.74711-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
RT-Send-CC: dllaurence [...] dslextreme.com
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 246
Download (untitled) / with headers
text/plain 246b
Attached is a git diff. If the Config/Auto.pm portion of the diff is applied the issue should be resolved. The diff also contains the a test that can be added to the test suite to demonstrate that the issue is fixed. I hope this helps. Dave
MIME-Version: 1.0
Subject: gitdiff_const_it.txt
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/plain; charset="utf-8"; name="gitdiff_const_it.txt"
Content-Disposition: inline; filename="gitdiff_const_it.txt"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1113
diff --git a/lib/Config/Auto.pm b/lib/Config/Auto.pm index ec8cfc7..eaa2e28 100644 --- a/lib/Config/Auto.pm +++ b/lib/Config/Auto.pm @@ -657,9 +657,9 @@ sub _check_hash_and_assign { my $fh = $self->fh; my %config; - while (<$fh>) { - next if /^\s*#/; - next unless /^\s*(.*?)\s*=\s*(.*?)\s*$/; + while ( my $in = <$fh>) { + next if $in =~ /^\s*#/; + next unless $in =~ /^\s*(.*?)\s*=\s*(.*?)\s*$/; my ($k, $v) = ($1, $2); diff --git a/t/06_const_it.t b/t/06_const_it.t new file mode 100644 index 0000000..ef2e8bf --- /dev/null +++ b/t/06_const_it.t @@ -0,0 +1,21 @@ +#!perl + +use Test::More; +use Test::Exception; +use strict; + +use Config::Auto; + +my $test_file = "/etc/fstab"; # A file found on any Unix/Linux machine. + +SKIP: { + skip "Can't test: $test_file doesn't exist on this system." + unless -e $test_file; + + for ( 'bar' ) { + lives_ok{ Config::Auto::parse($test_file) } + 'Config::Auto:parse() where $_ aliases a string literal.'; + } +} + +done_testing();
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-10815-1330787172-409.74711-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 59
This was applied and released as version 0.40 Many thanks.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.