Subject: | Config::General parses totally invalid data happily into nonsense |
I'm working on a module called Config::Any, designed to allow an app to
have configuration loaded from different kinds of config file, including
Config::General.
My understanding is that the following file is /not/ valid Config::General:
$ cat conf/conf.pl
{
name => 'TestApp',
'Controller::Foo' => {
foo => 'bar'
},
'Model::Baz' => {
qux => 'xyzzy'
}
}
Manifestly, it's Perl source, and it looks nothing like Apache-style
config. Not a <Tag>...</Tag> in sight. It looks to me that
Config::General makes an assumption that anything it's handed ought to
be valid for it to parse. It happens to be able to parse the file above,
and outputs a shocking mess:
$ perl -MConfig::General -MData::Dump -le 'my $cfg = {
Config::General->new("conf/conf.pl")->getall }; print
Data::Dump::dump($cfg)'
{
"'Controller::Foo'" => "> {",
"'Model::Baz'" => "> {",
foo => "> 'bar'",
name => "> 'TestApp',",
qux => "> 'xyzzy'",
"{" => "",
"}" => ["", ""],
"}," => "",
}
Is this by design? I think there should be some better heuristic to
detect whether the input file is indeed valid - the output above should
surely not occur? Am I missing something?
I realise you may be short of time to work on this. I'm happy to try to
work with you to develop a patch against Config::General, if you like.
Do you agree that C::G should be more strict about what input it
accepts, though? Obviously the user is at fault if they hand C::G Perl
code to parse, but it would make stuff a lot easier if C::G were to
validate its input more carefully.