diff --git a/General.pm b/General.pm index 85508b8..33d7e70 100644 --- a/General.pm +++ b/General.pm @@ -432,13 +432,13 @@ sub _open { # applied patch by AlexK fixing rt.cpan.org#41030 if ( !@include && defined $this->{ConfigPath} ) { - foreach my $dir (@{$this->{ConfigPath}}) { - my ($volume, $path, undef) = splitpath($basefile); - if ( -d catfile( $dir, $path ) ) { - push @include, grep { -f $_ } bsd_glob(catfile($dir, $basefile), GLOB_BRACE | GLOB_QUOTE); - last; - } - } + foreach my $dir (@{$this->{ConfigPath}}) { + my ($volume, $path, undef) = splitpath($basefile); + if ( -d catfile( $dir, $path ) ) { + push @include, grep { -f $_ } bsd_glob(catfile($dir, $basefile), GLOB_BRACE | GLOB_QUOTE); + last; + } + } } if (@include == 1) { @@ -722,12 +722,29 @@ sub _read { # bugfix rt.cpan.org#38635: support quoted filenames if ($this->{UseApacheInclude}) { - if (/^\s*include\s*(["'])(.*?)(?{IncludeGlob} && $opt =~ /opt/i && $incl_file !~ /[*?\[\{\\]/) { + # fix rt#107108 + # glob enabled && optional include && file is not already a glob: + # turn it into a singular matching glob, like: + # "file" => "[f][i][l][e]" and: + # "dir/file" => "dir/[f][i][l][e]" + # which IS a glob but only matches that particular file. if it + # doesn't exist, it will be ignored by _open(), just what + # we'd like to have when using IncludeOptional. + my ($vol,$dirs,$file) = splitpath( $incl_file ); + $incl_file = catpath($vol, $dirs, join '', map { "[$_]" } split //, $file); + } + } } else { if (/^\s*<>\\s*$/i) { diff --git a/General/Extended.pm b/General/Extended.pm index 0c73ff2..0e9e1c0 100644 --- a/General/Extended.pm +++ b/General/Extended.pm @@ -581,7 +581,7 @@ at the bottom if it exists. You can also search partway down the tree and ->find should return where you left off. For example, given the values B and the following -tree ( tags ommitted for brevity): +tree ( tags omitted for brevity): diff --git a/t/notincluded.conf.not b/t/notincluded.conf.not new file mode 100644 index 0000000..40ea569 --- /dev/null +++ b/t/notincluded.conf.not @@ -0,0 +1 @@ +honk=NONONO diff --git a/t/run.t b/t/run.t index 766d119..854b88b 100644 --- a/t/run.t +++ b/t/run.t @@ -8,7 +8,7 @@ use Data::Dumper; -use Test::More tests => 72; +use Test::More tests => 73; #use Test::More qw(no_plan); # ahem, we deliver the test code with a local copy of @@ -462,6 +462,19 @@ is_deeply( \%C38, { bit => { one => { honk=>'bonk' }, two => { honk=>'bonk' } } }, "Apache-style include" ); + +# verify fix for rt#107108, test support for IncludeOptional +my $conf38n = Config::General->new( -ConfigFile => "t/apache-include-opt.conf", + -IncludeAgain => 1, -IncludeGlob => 1, + -UseApacheInclude => 1 ); +my %C38n = $conf38n->getall; +is_deeply( \%C38n, { bit => { one => { nink=>'ack' }, + two => { honk=>'bonk' } + } }, "Apache-style IncludeOptional" ); + + + + #### 39 verifies bug rt#27225 # testing variable scope. # a variable shall resolve to the value defined in the current