mirror of
https://codeberg.org/scip/Config-General.git
synced 2025-12-16 20:21:01 +01:00
2.32
- fixed rt.cpan.org#24232 - import ENV vars only if defined - fixed rt.cpan.org#20742 - dont' overwrite a var if re-defined in current scope, interpolation failed for re-defined vars and used the value of the var defined in outer scope, not the current one. - fixed rt.cpan.org#17852 - a 0 as blockname were ignored. applied patch by SCOP to t/run.t to test for 0 in blocks. - applied most hints Perl::Critic had about Config::General: o the functions ParseConfig SaveConfig SaveConfigString must now imported implicitly. This might break existing code, but is easily to fix. o using IO::File instead of open(). o General.pm qualifies for "stern" level after all. - added much more tests to t/run.t for 'make test'. - using Test::More now. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@58 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Config::General::Extended - special Class based on Config::General
|
||||
#
|
||||
# Copyright (c) 2000-2006 Thomas Linden <tom@daemon.de>.
|
||||
# Copyright (c) 2000-2007 Thomas Linden <tlinden |AT| cpan.org>.
|
||||
# All Rights Reserved. Std. disclaimer applies.
|
||||
# Artificial License, same as perl itself. Have fun.
|
||||
#
|
||||
@@ -576,7 +576,7 @@ values under the given key will be overwritten.
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright (c) 2000-2006 Thomas Linden
|
||||
Copyright (c) 2000-2007 Thomas Linden
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
@@ -589,8 +589,7 @@ none known yet.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Thomas Linden <tom@daemon.de>
|
||||
|
||||
Thomas Linden <tlinden |AT| cpan.org>
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Config::General::Interpolated - special Class based on Config::General
|
||||
#
|
||||
# Copyright (c) 2001 by Wei-Hon Chen <plasmaball@pchome.com.tw>.
|
||||
# Copyright (c) 2000-2006 by Thomas Linden <tom@daemon.de>.
|
||||
# Copyright (c) 2000-2007 by Thomas Linden <tlinden |AT| cpan.org>.
|
||||
# All Rights Reserved. Std. disclaimer applies.
|
||||
# Artificial License, same as perl itself. Have fun.
|
||||
#
|
||||
@@ -75,23 +75,26 @@ sub _interpolate {
|
||||
else {
|
||||
# incorporate variables outside current scope(block) into
|
||||
# our scope to make them visible to _interpolate()
|
||||
|
||||
foreach my $key (keys %{$this->{stack}->{ $this->{level} - 1}->{ $this->{lastkey} }}) {
|
||||
$this->{stack}->{ $this->{level} }->{ $this->{prevkey} }->{$key} =
|
||||
$this->{stack}->{ $this->{level} - 1}->{ $this->{lastkey} }->{$key};
|
||||
if (! exists $this->{stack}->{ $this->{level} }->{ $this->{prevkey} }->{$key}) {
|
||||
# only import a variable if it is not re-defined in current scope! (rt.cpan.org bug #20742
|
||||
$this->{stack}->{ $this->{level} }->{ $this->{prevkey} }->{$key} = $this->{stack}->{ $this->{level} - 1}->{ $this->{lastkey} }->{$key};
|
||||
}
|
||||
}
|
||||
|
||||
$prevkey = $this->{prevkey};
|
||||
}
|
||||
|
||||
$value =~ s{$this->{regex}}{
|
||||
my $con = $1;
|
||||
my $var = $3;
|
||||
$var = lc($var) if $this->{LowerCaseNames};
|
||||
if (exists $this->{stack}->{ $this->{level} }->{ $prevkey }->{$var}) {
|
||||
$con . $this->{stack}->{ $this->{level} }->{ $prevkey }->{$var};
|
||||
my $var_lc = $this->{LowerCaseNames} ? lc($var) : $var;
|
||||
if (exists $this->{stack}->{ $this->{level} }->{ $prevkey }->{$var_lc}) {
|
||||
$con . $this->{stack}->{ $this->{level} }->{ $prevkey }->{$var_lc};
|
||||
}
|
||||
elsif ($this->{InterPolateEnv}) {
|
||||
# may lead to vulnerabilities, by default flag turned off
|
||||
$con . $ENV{$var};
|
||||
if (defined($ENV{$var})) {
|
||||
$con . $ENV{$var};
|
||||
}
|
||||
@@ -290,14 +293,14 @@ L<Config::General>
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Thomas Linden <tom@daemon.de>
|
||||
Thomas Linden <tlinden |AT| cpan.org>
|
||||
Autrijus Tang <autrijus@autrijus.org>
|
||||
Wei-Hon Chen <plasmaball@pchome.com.tw>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2001 by Wei-Hon Chen E<lt>plasmaball@pchome.com.twE<gt>.
|
||||
Copyright 2002-2006 by Thomas Linden <tom@daemon.de>.
|
||||
Copyright 2002-2007 by Thomas Linden <tlinden |AT| cpan.org>.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
|
||||
Reference in New Issue
Block a user