don't blindly untaint @INC
[p5sagit/local-lib.git] / lib / local / lib.pm
index bb29074..1153400 100644 (file)
@@ -66,11 +66,6 @@ DEATH
 
   $arg_store{path} = $class->resolve_path($arg_store{path});
   $class->setup_local_lib_for($arg_store{path}, $deactivating);
-
-  for (@INC) { # Untaint @INC
-    next if ref; # Skip entry if it is an ARRAY, CODE, blessed, etc.
-    m/(.*)/ and $_ = $1;
-  }
 }
 
 sub pipeline;
@@ -430,8 +425,7 @@ sub build_activate_environment_vars_for {
               $path,
               \'PERL_LOCAL_LIB_ROOT',
             ),
-    PERL_MB_OPT => "--install_base " . _mb_escape_path($path),
-    PERL_MM_OPT => "INSTALL_BASE=" . _mm_escape_path($path),
+    $class->installer_options_for($path),
     PERL5LIB =>
             _env_list_value(
               { interpolate => $interpolate, exists => 0, empty => '' },
@@ -486,7 +480,6 @@ sub build_deactivate_environment_vars_for {
   }
 
   my $perl_path = $class->install_base_perl_path($path);
-  my $arch_path = $class->install_base_arch_path($path);
   my $bin_path = $class->install_base_bin_path($path);
 
 
@@ -501,7 +494,7 @@ sub build_deactivate_environment_vars_for {
       {
         exists => 0,
         filter => sub {
-          $_ ne $perl_path && $_ ne $arch_path
+          $_ ne $perl_path
         },
       },
       \'PERL5LIB',
@@ -519,13 +512,21 @@ sub build_deactivate_environment_vars_for {
   # correspond with the new top of stack.
   if ($active_lls[0] eq $path) {
     my $new_top = $active_lls[1];
-    $env{PERL_MB_OPT} = defined($new_top) ? "--install_base "._mb_escape_path($new_top) : undef;
-    $env{PERL_MM_OPT} = defined($new_top) ? "INSTALL_BASE="._mm_escape_path($new_top) : undef;
+    my %opts = $class->installer_options_for($new_top);
+    $env{keys %opts} = values %opts;
   }
 
   return %env;
 }
 
+sub installer_options_for {
+  my ($class, $path) = @_;
+  return (
+    PERL_MM_OPT => defined $path ? "INSTALL_BASE="._mm_escape_path($path) : undef,
+    PERL_MB_OPT => defined $path ? "--install_base "._mb_escape_path($path) : undef,
+  )
+}
+
 sub build_deact_all_environment_vars_for {
   my ($class, $path, $interpolate) = @_;
 
@@ -533,7 +534,6 @@ sub build_deact_all_environment_vars_for {
 
   my %perl_paths = map { (
       $class->install_base_perl_path($_) => 1,
-      $class->install_base_arch_path($_) => 1
     ) } @active_lls;
   my %bin_paths = map { (
       $class->install_base_bin_path($_) => 1,
@@ -847,7 +847,7 @@ given path as the base directory.
 
 =item Arguments: $path, $interpolate
 
-=item Return value: \%environment_vars
+=item Return value: %environment_vars
 
 =back
 
@@ -895,21 +895,6 @@ Returns a path describing where to install the Perl modules for this local
 library installation. Appends the directories C<lib> and C<perl5> to the given
 path.
 
-=head2 install_base_arch_path
-
-=over 4
-
-=item Arguments: $path
-
-=item Return value: $install_base_arch_path
-
-=back
-
-Returns a path describing where to install the architecture-specific Perl
-modules for this local library installation. Based on the
-L</install_base_perl_path> method's return value, and appends the value of
-C<$Config{archname}>.
-
 =head2 install_base_bin_path
 
 =over 4
@@ -921,8 +906,7 @@ C<$Config{archname}>.
 =back
 
 Returns a path describing where to install the executable programs for this
-local library installation. Based on the L</install_base_perl_path> method's
-return value, and appends the directory C<bin>.
+local library installation. Appends the directory C<bin> to the given path.
 
 =head2 resolve_empty_path