X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FCrypt%2FGnuPG.pm;fp=rt%2Flib%2FRT%2FCrypt%2FGnuPG.pm;h=e0eacc75849bdfea273c061758f6ee1ec252396a;hb=d32f4c43b0fde5c18b8c2ee8f3d4cb9c6861a403;hp=91f974c06ea8e019b511f4f778a021c9bbf8a253;hpb=d6d7984aac204cfb374ac571b3b2871bf6aeabd5;p=freeside.git diff --git a/rt/lib/RT/Crypt/GnuPG.pm b/rt/lib/RT/Crypt/GnuPG.pm index 91f974c06..e0eacc758 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-2011 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -901,11 +901,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: $@"); + } } }