diff options
author | Tony Cook <tony@develop-help.com> | 2016-06-27 16:21:21 +1000 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2016-07-25 10:12:21 +0100 |
commit | d5892636c6daa6fb272c24255447ea3904e4612a (patch) | |
tree | 421f104409bd161711ff5fc95cfde721b77c64e0 | |
parent | 420d0f46a0e26de0c764259c7584efa63532fe0b (diff) | |
download | perl-d5892636c6daa6fb272c24255447ea3904e4612a.tar.gz |
cpan/: remove . from @INC when loading optional modules
-rw-r--r-- | cpan/CPAN/lib/App/Cpan.pm | 21 | ||||
-rw-r--r-- | cpan/CPAN/lib/CPAN.pm | 4 | ||||
-rw-r--r-- | cpan/Digest/Digest.pm | 6 | ||||
-rw-r--r-- | cpan/Encode/Encode.pm | 2 | ||||
-rw-r--r-- | cpan/ExtUtils-MakeMaker/lib/ExtUtils/Command.pm | 5 | ||||
-rw-r--r-- | cpan/File-Fetch/lib/File/Fetch.pm | 10 | ||||
-rw-r--r-- | cpan/HTTP-Tiny/lib/HTTP/Tiny.pm | 4 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm | 2 | ||||
-rw-r--r-- | cpan/IPC-Cmd/lib/IPC/Cmd.pm | 4 | ||||
-rw-r--r-- | cpan/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm | 7 | ||||
-rw-r--r-- | cpan/Memoize/Memoize.pm | 6 | ||||
-rw-r--r-- | cpan/Pod-Perldoc/lib/Pod/Perldoc.pm | 5 | ||||
-rw-r--r-- | cpan/Sys-Syslog/Syslog.pm | 2 | ||||
-rw-r--r-- | cpan/bignum/lib/bigint.pm | 2 | ||||
-rw-r--r-- | cpan/bignum/lib/bignum.pm | 2 | ||||
-rw-r--r-- | cpan/bignum/lib/bigrat.pm | 2 | ||||
-rw-r--r-- | cpan/libnet/lib/Net/Config.pm | 7 |
17 files changed, 81 insertions, 10 deletions
diff --git a/cpan/CPAN/lib/App/Cpan.pm b/cpan/CPAN/lib/App/Cpan.pm index e8c9bb78ee..3fac04d346 100644 --- a/cpan/CPAN/lib/App/Cpan.pm +++ b/cpan/CPAN/lib/App/Cpan.pm @@ -530,9 +530,20 @@ sub AUTOLOAD { 1 } sub DESTROY { 1 } } +# load a module without searching the default entry for the current +# directory +sub _safe_load_module { + my $name = shift; + + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; + + eval "require $name; 1"; +} + sub _init_logger { - my $log4perl_loaded = eval "require Log::Log4perl; 1"; + my $log4perl_loaded = _safe_load_module("Log::Log4perl"); unless( $log4perl_loaded ) { @@ -993,7 +1004,7 @@ sub _load_local_lib # -I { $logger->debug( "Loading local::lib" ); - my $rc = eval { require local::lib; 1; }; + my $rc = _safe_load_module("local::lib"); unless( $rc ) { $logger->die( "Could not load local::lib" ); } @@ -1121,7 +1132,7 @@ sub _get_file { my $path = shift; - my $loaded = eval "require LWP::Simple; 1;"; + my $loaded = _safe_load_module("LWP::Simple"); croak "You need LWP::Simple to use features that fetch files from CPAN\n" unless $loaded; @@ -1143,7 +1154,7 @@ sub _gitify { my $args = shift; - my $loaded = eval "require Archive::Extract; 1;"; + my $loaded = _safe_load_module("Archive::Extract"); croak "You need Archive::Extract to use features that gitify distributions\n" unless $loaded; @@ -1207,7 +1218,7 @@ sub _show_Changes sub _get_changes_file { croak "Reading Changes files requires LWP::Simple and URI\n" - unless eval "require LWP::Simple; require URI; 1"; + unless _safe_load_module("LWP::Simple") && _safe_load_module("URI"); my $url = shift; diff --git a/cpan/CPAN/lib/CPAN.pm b/cpan/CPAN/lib/CPAN.pm index f4544f0939..25bf3494a8 100644 --- a/cpan/CPAN/lib/CPAN.pm +++ b/cpan/CPAN/lib/CPAN.pm @@ -1104,6 +1104,8 @@ sub has_usable { ] }; if ($usable->{$mod}) { + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; for my $c (0..$#{$usable->{$mod}}) { my $code = $usable->{$mod}[$c]; my $ret = eval { &$code() }; @@ -1146,6 +1148,8 @@ sub has_inst { $CPAN::META->{dontload_hash}{$mod}||=1; # unsafe meta access, ok return 0; } + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; my $file = $mod; my $obj; $file =~ s|::|/|g; diff --git a/cpan/Digest/Digest.pm b/cpan/Digest/Digest.pm index c3355a8bd4..299e25e0b7 100644 --- a/cpan/Digest/Digest.pm +++ b/cpan/Digest/Digest.pm @@ -38,7 +38,11 @@ sub new unless (exists ${"$class\::"}{"VERSION"}) { my $pm_file = $class . ".pm"; $pm_file =~ s{::}{/}g; - eval { require $pm_file }; + eval { + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; + require $pm_file + }; if ($@) { $err ||= $@; next; diff --git a/cpan/Encode/Encode.pm b/cpan/Encode/Encode.pm index d2ac30f748..dce6c5415e 100644 --- a/cpan/Encode/Encode.pm +++ b/cpan/Encode/Encode.pm @@ -56,6 +56,8 @@ require Encode::Config; eval { local $SIG{__DIE__}; local $SIG{__WARN__}; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; require Encode::ConfigLocal; }; diff --git a/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Command.pm b/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Command.pm index 4cc8d62608..34e85decfb 100644 --- a/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Command.pm +++ b/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Command.pm @@ -20,7 +20,10 @@ if( $Is_VMS ) { my $vms_efs; my $vms_case; - if (eval { local $SIG{__DIE__}; require VMS::Feature; }) { + if (eval { local $SIG{__DIE__}; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; + require VMS::Feature; }) { $vms_unix_rpt = VMS::Feature::current("filename_unix_report"); $vms_efs = VMS::Feature::current("efs_charset"); $vms_case = VMS::Feature::current("efs_case_preserve"); diff --git a/cpan/File-Fetch/lib/File/Fetch.pm b/cpan/File-Fetch/lib/File/Fetch.pm index 7d6a263e2b..5a8799b76a 100644 --- a/cpan/File-Fetch/lib/File/Fetch.pm +++ b/cpan/File-Fetch/lib/File/Fetch.pm @@ -567,6 +567,8 @@ sub _lwp_fetch { }; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; unless( can_load( modules => $use_list ) ) { $METHOD_FAIL->{'lwp'} = 1; return; @@ -619,6 +621,8 @@ sub _httptiny_fetch { }; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; unless( can_load(modules => $use_list) ) { $METHOD_FAIL->{'httptiny'} = 1; return; @@ -658,6 +662,8 @@ sub _httplite_fetch { }; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; unless( can_load(modules => $use_list) ) { $METHOD_FAIL->{'httplite'} = 1; return; @@ -733,6 +739,8 @@ sub _iosock_fetch { 'IO::Select' => '0.0', }; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; unless( can_load(modules => $use_list) ) { $METHOD_FAIL->{'iosock'} = 1; return; @@ -814,6 +822,8 @@ sub _netftp_fetch { check( $tmpl, \%hash ) or return; ### required modules ### + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; my $use_list = { 'Net::FTP' => 0 }; unless( can_load( modules => $use_list ) ) { diff --git a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm index 52887d18bd..8b62a2772c 100644 --- a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm +++ b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm @@ -485,6 +485,8 @@ sub can_ssl { my($ok, $reason) = (1, ''); # Need IO::Socket::SSL 1.42 for SSL_create_ctx_callback + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; unless (eval {require IO::Socket::SSL; IO::Socket::SSL->VERSION(1.42)}) { $ok = 0; $reason .= qq/IO::Socket::SSL 1.42 must be installed for https support\n/; @@ -1441,6 +1443,8 @@ sub _find_CA_file { return $self->{SSL_options}->{SSL_ca_file}; } + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; return Mozilla::CA::SSL_ca_file() if eval { require Mozilla::CA; 1 }; diff --git a/cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm b/cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm index eab345916a..92a04a45d9 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm @@ -27,6 +27,8 @@ Exporter::export_ok_tags('all'); BEGIN { + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; eval ' use IO::Uncompress::Adapter::Inflate 2.069 ;'; eval ' use IO::Uncompress::Adapter::Bunzip2 2.069 ;'; eval ' use IO::Uncompress::Adapter::LZO 2.069 ;'; diff --git a/cpan/IPC-Cmd/lib/IPC/Cmd.pm b/cpan/IPC-Cmd/lib/IPC/Cmd.pm index 6a82bdff9b..84ad0a0371 100644 --- a/cpan/IPC-Cmd/lib/IPC/Cmd.pm +++ b/cpan/IPC-Cmd/lib/IPC/Cmd.pm @@ -142,6 +142,8 @@ sub can_use_ipc_run { return if IS_WIN98; ### if we don't have ipc::run, we obviously can't use it. + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; return unless can_load( modules => { 'IPC::Run' => '0.55' }, verbose => ($WARN && $verbose), @@ -169,6 +171,8 @@ sub can_use_ipc_open3 { ### IPC::Open3 works on every non-VMS platform, but it can't ### capture buffers on win32 :( + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; return unless can_load( modules => { map {$_ => '0.0'} qw|IPC::Open3 IO::Select Symbol| }, verbose => ($WARN && $verbose), diff --git a/cpan/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm b/cpan/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm index 30760f3c26..9465c529c8 100644 --- a/cpan/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm +++ b/cpan/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm @@ -134,7 +134,12 @@ sub load_loc { my $pkg = join('::', grep { defined and length } $args{Class}, $args{Subclass}); return $Loc{$pkg} if exists $Loc{$pkg}; - eval { require Locale::Maketext::Lexicon; 1 } or return; + eval { + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; + require Locale::Maketext::Lexicon; + 1 + } or return; $Locale::Maketext::Lexicon::VERSION > 0.20 or return; eval { require File::Spec; 1 } or return; diff --git a/cpan/Memoize/Memoize.pm b/cpan/Memoize/Memoize.pm index 9a58c4ac74..b566f21b96 100644 --- a/cpan/Memoize/Memoize.pm +++ b/cpan/Memoize/Memoize.pm @@ -184,7 +184,11 @@ sub _my_tie { } my $modulefile = $module . '.pm'; $modulefile =~ s{::}{/}g; - eval { require $modulefile }; + eval { + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; + require $modulefile + }; if ($@) { croak "Memoize: Couldn't load hash tie module `$module': $@; aborting"; } diff --git a/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm b/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm index 84f6624f36..d35d0a0a91 100644 --- a/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm +++ b/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm @@ -575,6 +575,9 @@ sub find_good_formatter_class { my @class_list = @{ $self->{'formatter_classes'} || [] }; $self->die( "WHAT? Nothing in the formatter class list!?" ) unless @class_list; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; + my $good_class_found; foreach my $c (@class_list) { DEBUG > 4 and print "Trying to load $c...\n"; @@ -1006,6 +1009,8 @@ sub new_translator { # $tr = $self->new_translator($lang); my $self = shift; my $lang = shift; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; my $pack = 'POD2::' . uc($lang); eval "require $pack"; if ( !$@ && $pack->can('new') ) { diff --git a/cpan/Sys-Syslog/Syslog.pm b/cpan/Sys-Syslog/Syslog.pm index 25164af320..eed224a7c4 100644 --- a/cpan/Sys-Syslog/Syslog.pm +++ b/cpan/Sys-Syslog/Syslog.pm @@ -888,6 +888,8 @@ sub silent_eval (&) { sub can_load { my ($module, $verbose) = @_; local($SIG{__DIE__}, $SIG{__WARN__}, $@); + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; my $loaded = eval "use $module; 1"; warn $@ if not $loaded and $verbose; return $loaded diff --git a/cpan/bignum/lib/bigint.pm b/cpan/bignum/lib/bigint.pm index a47191e271..e8ad732551 100644 --- a/cpan/bignum/lib/bigint.pm +++ b/cpan/bignum/lib/bigint.pm @@ -315,6 +315,8 @@ sub import { } else { # see if we can find Math::BigInt::Lite if (!defined $a && !defined $p) { # rounding won't work to well + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; if (eval { require Math::BigInt::Lite; 1 }) { @import = (); # :constant in Lite, not MBI Math::BigInt::Lite->import(':constant'); diff --git a/cpan/bignum/lib/bignum.pm b/cpan/bignum/lib/bignum.pm index 90d5db5aed..b7449d9c4e 100644 --- a/cpan/bignum/lib/bignum.pm +++ b/cpan/bignum/lib/bignum.pm @@ -157,6 +157,8 @@ sub import { else { # see if we can find Math::BigInt::Lite if (!defined $a && !defined $p) { # rounding won't work to well + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; if (eval { require Math::BigInt::Lite; 1 }) { @import = (); # :constant in Lite, not MBI Math::BigInt::Lite->import(':constant'); diff --git a/cpan/bignum/lib/bigrat.pm b/cpan/bignum/lib/bigrat.pm index 79fe84d9f7..a4489e8617 100644 --- a/cpan/bignum/lib/bigrat.pm +++ b/cpan/bignum/lib/bigrat.pm @@ -150,6 +150,8 @@ sub import { else { # see if we can find Math::BigInt::Lite if (!defined $a && !defined $p) { # rounding won't work to well + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; if (eval { require Math::BigInt::Lite; 1 }) { @import = (); # :constant in Lite, not MBI Math::BigInt::Lite->import(':constant'); diff --git a/cpan/libnet/lib/Net/Config.pm b/cpan/libnet/lib/Net/Config.pm index 3aa547eb38..0eed8c9309 100644 --- a/cpan/libnet/lib/Net/Config.pm +++ b/cpan/libnet/lib/Net/Config.pm @@ -24,7 +24,12 @@ our $VERSION = "3.08"; our($CONFIGURE, $LIBNET_CFG); -eval { local $SIG{__DIE__}; require Net::LocalCfg }; +eval { + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; + local $SIG{__DIE__}; + require Net::LocalCfg; +}; our %NetConfig = ( nntp_hosts => [], |