Package: mailscripts Severity: wishlist I needed a utility for base64-decoding text parts of MIME messages.
All the tools I tried would (i) fail to crlf->lf convert the text part (as is needed) or (ii) have an interface which was just too inconvenient. Or both. I'm afraid I have not supplied a manpage, help message, etc. This program is useful with formail to work around a bug in git-am, where if it gets a base64-encoded patch it fails because the base64 correctly contains cr-lf line endings. Ian.
#!/usr/bin/perl -w # Copyright (C)2019 Citrix plc # Author: Ian Jackson <ian.jack...@eu.citrix.com> # GPLv3+ use strict; use MIME::Parser; die if @ARGV; my $p=new MIME::Parser; $p->output_to_core(1); my $e=$p->parse(\*STDIN); sub decode_entity ($); sub decode_entity ($) { my ($e) = @_; my $t = $e->effective_type(); if ($t =~ m{^text/}) { my $b = $e->bodyhandle(); if ($b) { my @l = $b->as_lines(); s/\r$// foreach @l; my $b2 = new MIME::Body::InCore \@l; $e->bodyhandle($b2); $e->head->replace("Content-Transfer-Encoding","8bit"); } } foreach my $part ($e->parts()) { decode_entity($part); } } decode_entity($e); $e->print(\*STDOUT);