You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2007/01/10 07:22:19 UTC
svn commit: r494733 -
/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
Author: felicity
Date: Tue Jan 9 22:22:18 2007
New Revision: 494733
URL: http://svn.apache.org/viewvc?view=rev&rev=494733
Log:
bug 5288: switch ArchiveIterator to using the three-argument version of open() since otherwise leading and trailing whitespace is trimmed
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm?view=diff&rev=494733&r1=494732&r2=494733
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm Tue Jan 9 22:22:18 2007
@@ -527,18 +527,27 @@
sub _mail_open {
my ($file) = @_;
- my $expr;
+ # bug 5288: the "magic" version of open will strip leading and trailing
+ # whitespace from the expression. switch to the three-argument version
+ # of open which does not strip whitespace. see "perldoc -f open" and
+ # "perldoc perlipc" for more information.
+
+ # Assume that the file by default is just a plain file
+ my @expr = ( $file );
+ my $mode = '<';
+
+ # Handle different types of compressed files
if ($file =~ /\.gz$/) {
- $expr = "gunzip -cd $file |";
+ $mode = '-|';
+ unshift @expr, 'gunzip', '-cd';
}
elsif ($file =~ /\.bz2$/) {
- $expr = "bzip2 -cd $file |";
- }
- else {
- $expr = $file;
+ $mode = '-|';
+ unshift @expr, 'bzip2', '-cd';
}
- if (!open (INPUT, $expr)) {
+ # Go ahead and try to open the file
+ if (!open (INPUT, $mode, @expr)) {
warn "archive-iterator: unable to open $file: $!\n";
return 0;
}