Skip Menu |

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

Report information
The Basics
Id: 80006
Status: resolved
Priority: 0/
Queue: Config-General

People
Owner: tlinden [...] cpan.org
Requestors: brostad [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 2.48
  • 2.51
Fixed in: (no value)



Subject: Empty blocks with trailing whitespace causes parsing failure
My company is running a number of perl applications on Debian GNU/Linux 6.0.4 which comes with perl 5.10.1 installed - the perl version we use. All our file configurations are loaded using Config::General version 2.48, and recently I encountered a problem with this module. The problem manifested itself when someone entered an empty block into a configuration file, e.g. <block/> or <block></block>, which caused the module to croak with an error message of this kind Block "<RootElement>" has no EndBlock statement After reading through the documentation, which states that empty blocks can be used, and running a number of tests, I discovered that if an empty block has a trailing whitespace, Config::General fails to parse and load the file, but if none of the empty blocks have trailing whitespace - then all is fine. I've attached two trimmed config files, one that is OK and one that will fail, and a script for loading them both in succession. This illustrates that just one tiny whitespace can cause the entire module to croak. I've also tested this problem on Config::General version 2.51 and got the same result, it failed on empty blocks with trailing whitespace.
Subject: myconf.err
Download myconf.err
application/octet-stream 129b

Message body not shown because it is not plain text.

Subject: conf_test.pl
#!/usr/bin/perl -w use v5.10; use strict; use Data::Dumper; use Config::General qw{ParseConfig}; printf "[Using version %s of Config::General]\n", Config::General->VERSION; for my $f ('myconf.ok', 'myconf.err') { die "No such config file '$f'" unless -r $f; say "Loading config from $f ..."; eval { my %conf = ParseConfig(-ConfigFile => $f, -BackslashEscape => 1, -CComments => 0); if (my $partner_conf = $conf{location}{partner}) { printf "Successfully loaded config: %s\n", Dumper $partner_conf; } else { say "** Failed to load config from file '$f'"; } }; say "** Encountered error loading file '$f': $@" if $@; }
Subject: myconf.ok
Download myconf.ok
application/octet-stream 127b

Message body not shown because it is not plain text.

fixed in 2.52