I'm a perl novice trying to figure out MIME::Parser to decode mime parts of an email. I mostly have it working, but there's either a deficiency in the code, or other problem that is causing the message to not be decoded properly.
These are emails received from the Ubuntu security mailing list. Somehow they produce weird  characters throughout the text, while reading the email with alpine seems to decode it just fine.
Here is one snippet from the email after it's been decoded:
 Felix Wilhelm, Fermin J. Serna, Gabriel Campana and Kevin Hamacher
 discovered that Dnsmasq incorrectly handled DNS requests. A remote
 attacker could use this issue to cause Dnsmasq to crash, resulting in
 a denial of service, or possibly execute arbitrary code.Â
 (CVE-2017-14491)`
Here is the code snippet I'm using for this:
use MIME::Parser;
use MIME::Entity;
use MIME::WordDecoder;
use MIME::Tools;
use MIME::Decoder;
use Email::MIME;
my $parser = MIME::Parser->new;
$parser->extract_uuencode(1);
$parser->extract_nested_messages(1);
$parser->output_to_core(1);
my $buf;
while(<STDIN> ){
$buf .= $_;
}
my $entity = $parser->parse_data($buf);
my $subject = $entity->head->get('Subject');
my $from = $entity->head->get('From');
my $AdvDate = $entity->head->get('Date');
my @mailData;
my $msg = Email::MIME->new($buf);
$msg->walk_parts(sub {
my ($part) = @_;
#warn($part->content_type . ": " . $part->subparts);
if (($part->content_type =~ /text\/plain$/i) && !@mailData) {
#print $part->body;
@mailData = split( '\n', $part->body);
}
elsif (($part->content_type =~ /text\/plain; charset=\"?utf-8\"?/i) && !@mailData) {
#print $part->body;
@mailData = split( '\n', $part->body);
}
elsif (($part->content_type =~ /text\/plain; charset=\"?us-ascii\"?/i) && !@mailData) {
#print $part->body;
@mailData = split( '\n', $part->body);
}
elsif (($part->content_type =~ /text\/plain; charset=\"?windows-1252\"?/i) && !@mailData) {
#print $part->body;
@mailData = split( '\n', $part->body);
}
elsif (($part->content_type =~ /text\/plain; charset=\"?iso-8859-1\"?/i) && !@mailData) {
#print $part->body;
@mailData = split( '\n', $part->body);
}
});
Later I do various operations on $buf before writing it to a database.
I've placed a copy of one of the emails that exhibit this problem here
https://pastebin.com/raw/2csUvWup
Please let me know what other information I can provide to properly decode this email.