diff --git a/README b/README index 16f7eb8..b49a5e4 100644 --- a/README +++ b/README @@ -23,7 +23,7 @@ allows you to move/remove messages in a queue, but does not facilitate analyzing them. Usage: - smqdecode --body --config --flags --headers --submission + smqdecode --body --config --flags --headers --raw --submission --limit-body=[N,none] --message --metadata --skip-busy --queue --warnings --type=[all,pended,quarantined,temporary] --help --man --version diff --git a/smqdecode b/smqdecode index 8912b88..aca8b41 100644 --- a/smqdecode +++ b/smqdecode @@ -8,11 +8,11 @@ use warnings; use strict; my $copyright = << 'COPYRIGHT'; -Copyright (C) 2019,2020, 2021 Timothe Litt +Copyright (C) 2019,2020, 2021, 2022 Timothe Litt Use --man for license information. COPYRIGHT -our $VERSION = 'V1.005'; +our $VERSION = 'V1.006'; # License is in the POD at the end of this file. @@ -36,6 +36,7 @@ use warnings; use strict; use Carp; +use Encode( qw/decode encode/ ); use Fcntl( qw/:flock :seek/ ); use POSIX( qw/strftime/ ); @@ -612,7 +613,7 @@ sub dumpmeta { # Dump headers # -# $qf->dumpheaders( [$ofh] ) +# $qf->dumpheaders( $flags, [$ofh], $raw ) sub dumpheaders { my $qf = shift; @@ -625,7 +626,13 @@ sub dumpheaders { # 0x81 indicates macro expansion. # Present as '$' -- and quote any '$' as '\$' my $txt = $h->{H}; - $txt =~ s/([\$\x81])/$1 eq '$'? '\\$':'$'/ge unless( $raw ); + unless( $raw ) { + $txt =~ s/([\$\x81])/$1 eq '$'? '\\$':'$'/ge; + if( $txt =~ /=\?.+\?.+\?=/ ) { + $txt =~ s/\n\s+//g; + $txt = encode( 'utf-8', decode( 'MIME-Header', $txt ) ); + } + } print $ofh ( "$txt\n" ); if( $flags && keys %{ $h->{F} } ) { @@ -1051,7 +1058,7 @@ unless( __FILE__ =~ /\.pm$/ ) { require Getopt::Long; Getopt::Long->import( qw/GetOptions :config bundling/ ); - my( $meta, $headers, $body, $transcript, + my( $meta, $headers, $body, $transcript, $raw, $flags, $limit, $debug, $submit, $delete, $help, $man, $version, ); @@ -1068,6 +1075,7 @@ unless( __FILE__ =~ /\.pm$/ ) { 'man' => \$man, 'metadata|m!' => \$meta, 'queue|q=s' => \$opts{qdir}, + 'raw|r!' => \$raw, 'skip-busy|s!' => \$opts{skip}, 'submission|submit!' => \$submit, 'transcript|t!' => \$transcript, @@ -1128,7 +1136,7 @@ unless( __FILE__ =~ /\.pm$/ ) { $qf->dumpmeta if( $meta ); if( $headers ) { print( "\n" ) if( $meta ); - $qf->dumpheaders( $flags ); + $qf->dumpheaders( $flags, undef, $raw ); } if( $body ) { print( "\n" ) if( $meta || $headers ); @@ -1197,7 +1205,7 @@ smqdecode - Decode and extract sendmail queue entries =head1 SYNOPSIS - smqdecode --body --config --flags --headers --submission + smqdecode --body --config --flags --headers --raw --submission --limit-body=[N,none] --message --metadata --skip-busy --queue --warnings --type=[all,pended,quarantined,temporary] --delete @@ -1251,7 +1259,7 @@ The following options are provided. The short and long forms of each option have the same effect. The long form of a boolean option can be negated by specifying it as B<-->noB