Skip to content

Commit 8901dde

Browse files
committed
dist/: remove . from @inc when loading optional modules
I didn't update base.pm since that seems more likely to be loading modules *expected* to be in the current directory. Opinions welcome.
1 parent dcfbcce commit 8901dde

File tree

11 files changed

+47
-8
lines changed

11 files changed

+47
-8
lines changed

dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ sub _try_use { # Basically a wrapper around "require Modulename"
145145
print " About to use $module ...\n" if DEBUG;
146146
{
147147
local $SIG{'__DIE__'};
148+
local @INC = @INC;
149+
pop @INC if $INC[-1] eq '.';
148150
eval "require $module"; # used to be "use $module", but no point in that.
149151
}
150152
if($@) {

dist/IO/IO.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ sub import {
1818

1919
my @l = @_ ? @_ : qw(Handle Seekable File Pipe Socket Dir);
2020

21+
local @INC = @INC;
22+
pop @INC if $INC[-1] eq '.';
2123
eval join("", map { "require IO::" . (/(\w+)/)[0] . ";\n" } @l)
2224
or croak $@;
2325
}

dist/Locale-Maketext/lib/Locale/Maketext.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ sub _try_use { # Basically a wrapper around "require Modulename"
499499

500500
local $SIG{'__DIE__'};
501501
local $@;
502+
local @INC = @INC;
503+
pop @INC if $INC[-1] eq '.';
502504
eval "require $module"; # used to be "use $module", but no point in that.
503505

504506
if($@) {

dist/Net-Ping/lib/Net/Ping.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ sub ping_external {
410410
$timeout # Seconds after which ping times out
411411
) = @_;
412412

413-
eval { require Net::Ping::External; }
413+
eval {
414+
local @INC = @INC;
415+
pop @INC if $INC[-1] eq '.';
416+
require Net::Ping::External;
417+
}
414418
or croak('Protocol "external" not supported on your system: Net::Ping::External not found');
415419
return Net::Ping::External::ping(ip => $ip, timeout => $timeout);
416420
}

dist/PathTools/Cwd.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ if ($^O eq 'os2') {
4040
my $use_vms_feature;
4141
BEGIN {
4242
if ($^O eq 'VMS') {
43-
if (eval { local $SIG{__DIE__}; require VMS::Feature; }) {
43+
if (eval { local $SIG{__DIE__};
44+
local @INC = @INC;
45+
pop @INC if $INC[-1] eq '.';
46+
require VMS::Feature; }) {
4447
$use_vms_feature = 1;
4548
}
4649
}

dist/PathTools/lib/File/Spec/Cygwin.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ sub case_tolerant {
137137
if ($mntopts and ($mntopts =~ /,managed/)) {
138138
return 0;
139139
}
140-
eval { require Win32API::File; } or return 1;
140+
eval {
141+
local @INC = @INC;
142+
pop @INC if $INC[-1] eq '.';
143+
require Win32API::File;
144+
} or return 1;
141145
my $osFsType = "\0"x256;
142146
my $osVolName = "\0"x256;
143147
my $ouFsFlags = 0;

dist/PathTools/lib/File/Spec/VMS.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ via the C<DECC$FILENAME_UNIX_REPORT> CRTL feature.
3939

4040
my $use_feature;
4141
BEGIN {
42-
if (eval { local $SIG{__DIE__}; require VMS::Feature; }) {
42+
if (eval { local $SIG{__DIE__};
43+
local @INC = @INC;
44+
pop @INC if $INC[-1] eq '.';
45+
require VMS::Feature; }) {
4346
$use_feature = 1;
4447
}
4548
}

dist/PathTools/lib/File/Spec/Win32.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ Default: 1
9090
=cut
9191

9292
sub case_tolerant {
93-
eval { require Win32API::File; } or return 1;
93+
eval {
94+
local @INC = @INC;
95+
pop @INC if $INC[-1] eq '.';
96+
require Win32API::File;
97+
} or return 1;
9498
my $drive = shift || "C:";
9599
my $osFsType = "\0"x256;
96100
my $osVolName = "\0"x256;

dist/Storable/Storable.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ use vars qw($canonical $forgive_me $VERSION);
2525
$VERSION = '2.56';
2626

2727
BEGIN {
28-
if (eval { local $SIG{__DIE__}; require Log::Agent; 1 }) {
28+
if (eval {
29+
local $SIG{__DIE__};
30+
local @INC = @INC;
31+
pop @INC if $INC[-1] eq '.';
32+
require Log::Agent;
33+
1;
34+
}) {
2935
Log::Agent->import;
3036
}
3137
#

dist/Test/lib/Test.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,12 @@ sub _diff_complain {
505505
my($result, $expected, $detail, $prefix) = @_;
506506
return _diff_complain_external(@_) if $ENV{PERL_TEST_DIFF};
507507
return _diff_complain_algdiff(@_)
508-
if eval { require Algorithm::Diff; Algorithm::Diff->VERSION(1.15); 1; };
508+
if eval {
509+
local @INC = @INC;
510+
pop @INC if $INC[-1] eq '.';
511+
require Algorithm::Diff; Algorithm::Diff->VERSION(1.15);
512+
1;
513+
};
509514

510515
$told_about_diff++ or print $TESTERR <<"EOT";
511516
# $prefix (Install the Algorithm::Diff module to have differences in multiline

dist/base/lib/base.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ sub import {
9797
{
9898
local $SIG{__DIE__};
9999
my $fn = _module_to_filename($base);
100-
eval { require $fn };
100+
eval {
101+
local @INC = @INC;
102+
pop @INC if $INC[-1] eq '.';
103+
require $fn
104+
};
101105
# Only ignore "Can't locate" errors from our eval require.
102106
# Other fatal errors (syntax etc) must be reported.
103107
#

0 commit comments

Comments
 (0)