X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FCrypt%2FGnuPG.pm;h=6164a4241ed083d7500f1d2980051762d183edb8;hb=679854b8bbc65d112071111bbd7f34a6a481fb30;hp=233047820d2aa2ba6c46c531819c919a2ccf9152;hpb=9b328d940af56b9924a342192ebb0790478fa705;p=freeside.git diff --git a/rt/lib/RT/Crypt/GnuPG.pm b/rt/lib/RT/Crypt/GnuPG.pm index 233047820..6164a4241 100644 --- a/rt/lib/RT/Crypt/GnuPG.pm +++ b/rt/lib/RT/Crypt/GnuPG.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -905,11 +905,25 @@ sub FindProtectedParts { # sense) unnecessarily applies a base64 transfer encoding to PGP # mail (whose content is already base64-encoded). if ( $entity->bodyhandle->is_encoded and $entity->head->mime_encoding ) { - pipe( my ($read_decoded, $write_decoded) ); my $decoder = MIME::Decoder->new( $entity->head->mime_encoding ); if ($decoder) { - eval { $decoder->decode($io, $write_decoded) }; - $io = $read_decoded; + local $@; + eval { + my $buf = ''; + open my $fh, '>', \$buf + or die "Couldn't open scalar for writing: $!"; + binmode $fh, ":raw"; + $decoder->decode($io, $fh); + close $fh or die "Couldn't close scalar: $!"; + + open $fh, '<', \$buf + or die "Couldn't re-open scalar for reading: $!"; + binmode $fh, ":raw"; + $io = $fh; + 1; + } or do { + $RT::Logger->error("Couldn't decode body: $@"); + } } }