From: Brian Cassidy Date: Thu, 7 Feb 2008 23:01:08 +0000 (+0000) Subject: remove eval so the Perl loader dies on invalid content. X-Git-Tag: v0.12~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8af0a7cf96c671f13244fec2e0f15a4c13f2737d;p=p5sagit%2FConfig-Any.git remove eval so the Perl loader dies on invalid content. --- diff --git a/Changes b/Changes index 2adfc71..ce888cb 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Config-Any +0.12 XXX 2008 + - ensure Perl loader dies on a failed require() (RT #32995) + 0.11 Mon 28 Jan 2008 - fix subsection parsing for existing keys in INI files (RT #32726) - use from_json() if JSON version 2.x is available diff --git a/lib/Config/Any.pm b/lib/Config/Any.pm index 15005fc..dce93ce 100644 --- a/lib/Config/Any.pm +++ b/lib/Config/Any.pm @@ -6,7 +6,7 @@ use warnings; use Carp; use Module::Pluggable::Object (); -our $VERSION = '0.11'; +our $VERSION = '0.12'; =head1 NAME diff --git a/lib/Config/Any/Perl.pm b/lib/Config/Any/Perl.pm index 6a2e330..936efab 100644 --- a/lib/Config/Any/Perl.pm +++ b/lib/Config/Any/Perl.pm @@ -47,7 +47,7 @@ sub load { my $content; unless ( $content = $cache{ $file } ) { - $content = eval { require $file }; + $content = require $file; $cache{ $file } = $content; } diff --git a/t/63-invalid.t b/t/63-invalid.t new file mode 100644 index 0000000..932e93d --- /dev/null +++ b/t/63-invalid.t @@ -0,0 +1,14 @@ +use strict; +use warnings; + +use Test::More tests => 2; + +use Config::Any::Perl; + +{ + my $file = 't/conf/conf_invalid.pl'; + my $config = eval { Config::Any::Perl->load( $file ) }; + + ok( !$config, 'config load failed' ); + ok( $@, "error thrown ($@)" ); +} diff --git a/t/conf/conf_invalid.pl b/t/conf/conf_invalid.pl new file mode 100644 index 0000000..fdbc936 --- /dev/null +++ b/t/conf/conf_invalid.pl @@ -0,0 +1 @@ +this is not valid perl.