You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by gb...@apache.org on 2023/11/06 08:27:01 UTC
svn commit: r1913611 - in /spamassassin/trunk: lib/Mail/SpamAssassin/Util.pm t/extracttext.t
Author: gbechis
Date: Mon Nov 6 08:27:01 2023
New Revision: 1913611
URL: http://svn.apache.org/viewvc?rev=1913611&view=rev
Log:
make it possible to run external programs if the path contains spaces
and it's sorrounded by double quotes.
bz #8057
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
spamassassin/trunk/t/extracttext.t
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm?rev=1913611&r1=1913610&r2=1913611&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Mon Nov 6 08:27:01 2023
@@ -1934,10 +1934,32 @@ sub setuid_to_euid {
# helper app command-line open
sub helper_app_pipe_open {
+
+ my @cmdline;
+ my $startquote = 0;
+ my $ntok;
+ foreach my $tok ( @_ ) {
+ if(defined $tok && ($tok =~ /^\"/) && ($tok !~ /\"$/)) {
+ $startquote = 1;
+ }
+ if($startquote) {
+ $ntok .= " " if($tok !~ /^\"/);
+ $ntok =~ s/\"// if defined $ntok;
+ $ntok .= $tok;
+ }
+ if($startquote && defined $tok && ($tok =~ /\"$/)) {
+ $startquote = 0;
+ $ntok =~ s/\"// if defined $ntok;
+ push(@cmdline, $ntok);
+ undef $ntok;
+ } elsif(not $startquote) {
+ push(@cmdline, $tok);
+ }
+ }
if (RUNNING_ON_WINDOWS) {
- return helper_app_pipe_open_windows (@_);
+ return helper_app_pipe_open_windows (@cmdline);
} else {
- return helper_app_pipe_open_unix (@_);
+ return helper_app_pipe_open_unix (@cmdline);
}
}
Modified: spamassassin/trunk/t/extracttext.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/extracttext.t?rev=1913611&r1=1913610&r2=1913611&view=diff
==============================================================================
--- spamassassin/trunk/t/extracttext.t (original)
+++ spamassassin/trunk/t/extracttext.t Mon Nov 6 08:27:01 2023
@@ -5,9 +5,9 @@ use SATest; sa_t_init("extracttext");
use Mail::SpamAssassin::Util;
use Test::More;
-use constant PDFTOTEXT => eval { my $f = Mail::SpamAssassin::Util::find_executable_in_env_path('pdftotext'); ($f !~ /\s/)?$f:undef};
-use constant TESSERACT => eval { my $f = Mail::SpamAssassin::Util::find_executable_in_env_path('tesseract'); ($f !~ /\s/)?$f:undef};
-use constant CAT => eval { my $f = Mail::SpamAssassin::Util::find_executable_in_env_path('cat'); ($f !~ /\s/)?$f:undef};
+use constant PDFTOTEXT => eval { my $f = Mail::SpamAssassin::Util::find_executable_in_env_path('pdftotext'); ($f !~ /\s/)?$f:'"'.$f.'"'};
+use constant TESSERACT => eval { my $f = Mail::SpamAssassin::Util::find_executable_in_env_path('tesseract'); ($f !~ /\s/)?$f:'"'.$f.'"'};
+use constant CAT => eval { my $f = Mail::SpamAssassin::Util::find_executable_in_env_path('cat'); ($f !~ /\s/)?$f:'"'.$f.'"'};
my $tests = 0;
$tests += 2 if (PDFTOTEXT);