fix rt.cpan.org#104548

git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@102 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
Thomas von Dein
2015-05-20 17:28:38 +00:00
parent 176b3e91d2
commit 61ed23ca3a
4 changed files with 23 additions and 5 deletions

View File

@@ -1,3 +1,10 @@
2.57 - fix rt.cpan.org#104548, dont allow special chars like newline
or < in keys, which leads to faile when saving.
2.56 - fix rt.cpan.org#95325
2.55 - fix rt.cpan.org#95314
2.54 - fixed rt.cpan.org#39814. changed the order of pre-processing 2.54 - fixed rt.cpan.org#39814. changed the order of pre-processing
in _read(): 1) remove comments, 2) check for continuation, in _read(): 1) remove comments, 2) check for continuation,
3) remove empty lines. 3) remove empty lines.

View File

@@ -5,7 +5,7 @@
# config values from a given file and # config values from a given file and
# return it as hash structure # return it as hash structure
# #
# Copyright (c) 2000-2014 Thomas Linden <tlinden |AT| cpan.org>. # Copyright (c) 2000-2015 Thomas Linden <tlinden |AT| cpan.org>.
# All Rights Reserved. Std. disclaimer applies. # All Rights Reserved. Std. disclaimer applies.
# Artistic License, same as perl itself. Have fun. # Artistic License, same as perl itself. Have fun.
# #
@@ -32,7 +32,7 @@ use Carp::Heavy;
use Carp; use Carp;
use Exporter; use Exporter;
$Config::General::VERSION = "2.56"; $Config::General::VERSION = "2.57";
use vars qw(@ISA @EXPORT_OK); use vars qw(@ISA @EXPORT_OK);
use base qw(Exporter); use base qw(Exporter);
@@ -1258,6 +1258,11 @@ sub _store {
my $config_string = q(); my $config_string = q();
foreach my $entry ( $this->{SaveSorted} ? sort keys %$config : keys %$config ) { foreach my $entry ( $this->{SaveSorted} ? sort keys %$config : keys %$config ) {
# fix rt#104548
if ($entry =~ /[<>\n\r]/) {
croak "Config::General: current key contains invalid characters: $entry!\n";
}
if (ref($config->{$entry}) eq 'ARRAY') { if (ref($config->{$entry}) eq 'ARRAY') {
if( $this->{ForceArray} && scalar @{$config->{$entry}} == 1 && ! ref($config->{$entry}->[0]) ) { if( $this->{ForceArray} && scalar @{$config->{$entry}} == 1 && ! ref($config->{$entry}->[0]) ) {
# a single value array forced to stay as array # a single value array forced to stay as array
@@ -2748,7 +2753,7 @@ Thomas Linden <tlinden |AT| cpan.org>
=head1 VERSION =head1 VERSION
2.56 2.57
=cut =cut

2
README
View File

@@ -104,4 +104,4 @@ AUTHOR
VERSION VERSION
2.56 2.57

View File

@@ -8,7 +8,7 @@
use Data::Dumper; use Data::Dumper;
use Test::More tests => 71; use Test::More tests => 72;
#use Test::More qw(no_plan); #use Test::More qw(no_plan);
# ahem, we deliver the test code with a local copy of # ahem, we deliver the test code with a local copy of
@@ -742,3 +742,9 @@ is($hash54{val}, qq(\\\$notavar:\\blah), "check -NoEscape");
my $cfg55 = new Config::General( -ConfigFile => "t/cfg.55" ); my $cfg55 = new Config::General( -ConfigFile => "t/cfg.55" );
my %hash55 = $cfg55->getall(); my %hash55 = $cfg55->getall();
is($hash55{b}, "nochop", "check continuation followed by empty line"); is($hash55{b}, "nochop", "check continuation followed by empty line");
my $cfg56 = Config::General->new();
eval {
$cfg56->save_file("t/56.out", { "new\nline" => 9, "brack<t" => 8 });
};
ok($@, "catch special chars in keys");