Skip to content

Commit

Permalink
Item10240: make extender.pl handle vars embedded in other vars, a la …
Browse files Browse the repository at this point in the history
…Foswiki::Configure::Load

git-svn-id: http://svn.foswiki.org/trunk@13737 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Jan 19, 2012
1 parent 9a26a72 commit 5e7748f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Load.pm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ sub expandValue {
}
elsif ( defined( $_[0] ) ) {
while (
$_[0] =~ s/(\$Foswiki::cfg{[[A-Za-z0-9{}]+})/_handleExpand($1)/ge )
$_[0] =~ s/(\$Foswiki::cfg{[A-Za-z0-9{}]+})/_handleExpand($1)/ge )
{
}
}
Expand Down
17 changes: 15 additions & 2 deletions core/tools/extender.pl
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ sub _validatePerlModule {
---++ StaticMethod getScriptDir( )
This routine will recover the Script Directory from LocalSite.cfg
without processing the entire file.
without processing the entire file (unless it has to to expand embedded vars)
=cut

Expand Down Expand Up @@ -504,7 +504,20 @@ sub getScriptDir {
my $cfgfile = do { local $/; <$cfg> };

$cfgfile =~ m/$reBinDir/ms;
return $1 || $2;

my $val = $1 || $2;
if ($val =~ /\$Foswiki::cfg/) {
# if there's at least one unexpanded cfg var in the value,
# slurp LSC and expand
local %Foswiki::cfg; # local namespace, won't pollute anything else
eval $cfgfile;
unless ($@) {
while ($val =~ s<(\$Foswiki::cfg{[A-Za-z0-9{}]+})>
<eval $1>gex) {
}
}
}
return $val;

}

Expand Down

0 comments on commit 5e7748f

Please sign in to comment.