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.
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
#!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();
RT-Send-CC: dllaurence [...] dslextreme.com
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
Subject: gitdiff_const_it.txt
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();
This was applied and released as version 0.40 Many thanks.