You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by si...@apache.org on 2022/08/04 11:08:12 UTC

svn commit: r1903224 - /spamassassin/trunk/t/SATest.pm

Author: sidney
Date: Thu Aug  4 11:08:11 2022
New Revision: 1903224

URL: http://svn.apache.org/viewvc?rev=1903224&view=rev
Log:
Add defined check for a value that can end up undefined

Modified:
    spamassassin/trunk/t/SATest.pm

Modified: spamassassin/trunk/t/SATest.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/SATest.pm?rev=1903224&r1=1903223&r2=1903224&view=diff
==============================================================================
--- spamassassin/trunk/t/SATest.pm (original)
+++ spamassassin/trunk/t/SATest.pm Thu Aug  4 11:08:11 2022
@@ -75,12 +75,15 @@ BEGIN {
     $ENV{'PATH'} =
       join(';', # filter for only dirs that are canonical absolute paths that exist
         map {
-          my $pathdir = $_;
-            $pathdir =~ s/\\*\z//;
-              File::Spec->canonpath(Cwd::realpath($pathdir)) =~ /^(.*)\z/s;
-              my $abspathdir = $1; # untaint it
-               ((lc $pathdir eq lc $abspathdir) and (-d $abspathdir))?($abspathdir):()
+              my $pathdir = $_;
+              $pathdir =~ s/\\*\z//;
+              my $abspathdir = File::Spec->canonpath(Cwd::realpath($pathdir));
+              if (defined $abspathdir) {
+                $abspathdir  =~ /^(.*)\z/s;
+                $abspathdir = $1; # untaint it
               }
+              ((defined $abspathdir) and (lc $pathdir eq lc $abspathdir) and (-d $abspathdir))?($abspathdir):()
+            }
           @pathdirs);
   }
   
@@ -142,13 +145,16 @@ sub sa_t_init {
     my $inc_opts =
       join(' -I', # filter for only dirs that are canonical absolute paths that exist
         map {
-          my $pathdir = $_;
-            $pathdir =~ s/[\/\\]*\z//; # remove trailing directory separators
-            File::Spec->canonpath(Cwd::realpath($pathdir)) =~ /^(.*)\z/s;
-            my $abspathdir = $1; # untaint it
-             ((lc $pathdir eq lc $abspathdir) and (-d $abspathdir))?($abspathdir):()
+              my $pathdir = $_;
+              $pathdir =~ s/[\/\\]*\z//; # remove trailing directory separators
+              my $abspathdir = File::Spec->canonpath(Cwd::realpath($pathdir));
+              if (defined $abspathdir) {
+                 $abspathdir =~ /^(.*)\z/s;
+                 $abspathdir = $1; # untaint it
+              }
+              ((defined $abspathdir) and (lc $pathdir eq lc $abspathdir) and (-d $abspathdir))?($abspathdir):()
             }
-	   @pathdirs);
+           @pathdirs);
     $perl_cmd .= " -I$inc_opts" if ($inc_opts);
   }