@@ -20,7 +20,7 @@ use strict;
20
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
21
# or visit http://www.gnu.org/copyleft/gpl.html
22
22
#
23
- # 20050528 raf <raf@raf.org>
23
+ # 20050926 raf <raf@raf.org>
24
24
25
25
=head1 NAME
26
26
@@ -272,10 +272,10 @@ delete windows executables (with output in mailbox format):
272
272
273
273
=head1 REQUIREMENTS
274
274
275
- MS Word and RTF documents are translated into plain text using I< catdoc(1) > .
276
- If I< textmail (1) > can't find I<catdoc(1) > , then MS Word and RTF attachments
277
- are left intact. So make sure that I<catdoc(1) > is installed and in the
278
- C<$PATH > .
275
+ MS Word and RTF documents are translated into plain text using
276
+ I< antiword (1) > or I<catdoc(1) > . If I< textmail(1) > can't find I< antiword > or
277
+ I<catdoc(1) > , then MS Word and RTF attachments are left intact. So make sure
278
+ that I< antiword(1) > or I< catdoc(1) > is installed and in the C<$PATH > .
279
279
280
280
MS Excel documents are translated into csv files using I<xls2csv(1) > . If
281
281
I<textmail(1) > can't find I<xls2csv(1) > , then MS Excel attachments are left
@@ -308,6 +308,7 @@ temporary directory will be created.
308
308
=head1 SEE ALSO
309
309
310
310
I<procmail(1) > ,
311
+ I<antiword(1) > ,
311
312
I<catdoc(1) > ,
312
313
I<xls2csv(1) > ,
313
314
I<lynx(1) > ,
@@ -318,7 +319,7 @@ C<http://raf.org/minimail/>
318
319
319
320
=head1 AUTHOR
320
321
321
- 20050528 raf <raf@raf.org>
322
+ 20050926 raf <raf@raf.org>
322
323
323
324
=head1 URL
324
325
@@ -891,14 +892,15 @@ nroff if exists $opt{r};
891
892
html if exists $opt {w};
892
893
my $mailbox = exists $opt {M};
893
894
my $catdoc = find('catdoc');
895
+ my $antiword = find('antiword') || $catdoc ;
894
896
my $xls2csv = find('xls2csv');
895
897
my $lynx = find('lynx');
896
898
my $pdftotext = find('pdftotext');
897
899
my $mktemp = find('mktemp');
898
900
paths() if exists $opt {'?'};
899
901
my @exe = qw(com exe pif dll ocx scr vbs js);
900
902
my $force = exists $opt {f};
901
- my $remove_word = (defined $catdoc || $force ) && ! exists $opt {W};
903
+ my $remove_word = (defined $antiword || $force ) && ! exists $opt {W};
902
904
my $remove_excel = (defined $xls2csv || $force ) && ! exists $opt {E};
903
905
my $remove_html = (defined $lynx || $force ) && ! exists $opt {H};
904
906
my $remove_rtf = (defined $catdoc || $force ) && ! exists $opt {R};
@@ -931,15 +933,17 @@ formail(sub { <> }, sub
931
933
{
932
934
my $m = mail2singlepart(textmail(mail2multipart(shift)));
933
935
delete_header($m , qr/(?:content-length|lines)/i);
934
- $m = mail2mbox($m ) if $mailbox ;
935
- print mail2str($m );
936
+ print mail2str($mailbox ? mail2mbox($m ) : $m );
936
937
});
937
938
939
+ rmdir $tmp or system "rm -rf $tmp ";
940
+
938
941
# Print paths to help applications then exit
939
942
940
943
sub paths
941
944
{
942
- print(defined $catdoc ? $catdoc : "catdoc not found: MS Word and RTF will not be translated", "\n ");
945
+ print(defined $antiword ? $antiword : "antiword/catdoc not found: MS Word will not be translated", "\n ");
946
+ print(defined $catdoc ? $catdoc : "catdoc not found: MS RTF will not be translated", "\n ");
943
947
print(defined $xls2csv ? $xls2csv : "xls2csv not found: MS Excel with not be translated", "\n ");
944
948
print(defined $lynx ? $lynx : "lynx not found: HTML will not be translated", "\n ");
945
949
print(defined $pdftotext ? $pdftotext : "pdftotext not found: PDF will not be translated", "\n ");
@@ -994,11 +998,11 @@ sub textmail
994
998
995
999
for (my $i = 0; $i < @parts ; ++$i )
996
1000
{
997
- # Replace MS Word attachments with plain text (via catdoc)
1001
+ # Replace MS Word attachments with plain text (via antiword/ catdoc)
998
1002
999
1003
if ($remove_word && isa($parts [$i ], qr/.*ms-?word/i, qr/\. doc$/i))
1000
1004
{
1001
- $parts [$i ] = translate($parts [$i ], 'doc', 'txt', $catdoc );
1005
+ $parts [$i ] = translate($parts [$i ], 'doc', 'txt', $antiword );
1002
1006
next;
1003
1007
}
1004
1008
@@ -1118,9 +1122,10 @@ sub translate
1118
1122
1119
1123
return $part if !defined $cmd && !$force ;
1120
1124
my $origpath = filename($part );
1125
+ $origpath .= '.' . $ext [0] unless $origpath =~ /\. (?:@{[join '|', @ext ]})$/i;
1121
1126
my $textpath = $origpath ;
1122
1127
$textpath =~ s/\. (?:@{[join '|', @ext ]})$/ .$fmt /i;
1123
- $textpath .= ".$fmt " unless $textpath =~ / \.\Q $fmt \E $/i ;
1128
+ $textpath .= ".$fmt " if $textpath eq $origpath ;
1124
1129
return newmail(filename => $textpath , body => '') if !defined $cmd && $force ;
1125
1130
my $origdata = body($part );
1126
1131
open A, ">$tmp /$origpath " and do { print A $origdata ; close A };
0 commit comments