Subject: | Mail::Header->unfold and ->fold don't work |
Two issues:
- Mail::Header->unfold keeps the spaces instead of removing them.
- Mail::Header->fold(72) seems to do nothing at all, at least in my test case where the header value contains no spaces.
See the testcase (using Test::More) attached to fully reproduce the issue.
--
Olivier Mengué - http://perlresume.org/DOLMEN
Subject: | unfold-fold-2.12-failure.pl |
#!perl
use Test::More 0.98;
use Mail::Header;
my $input = <<'EOF';
Import-Package: fr.bytel.mf.device;version="3.2",fr.bytel.mf.smartobject
;version="3.2",fr.bytel.mf.util;version="3.2",javax.net.ssl;resolution:
=optional,org.osgi.framework;version="1.3.0",org.osgi.service.event;ver
sion="1.1.0",org.osgi.util.tracker;version="[1.3,2)"
EOF
open my $in, '<', \$input or die;
my $head = Mail::Header->new($in, FoldLength => 72);
close $in;
$head->unfold;
my $imppkg = $head->get('Import-Package');
#note $imppkg;
unlike($imppkg, qr/ /, "no spaces!");
# Fix it
$imppkg =~ s/ //g;
$head->replace('Import-Package', $imppkg);
# Fold back
$head->fold(72);
my $output = $head->as_string;
like($input, qr/\n /s, 'input is folded!'); # Just to check our regexp works
like($output, qr/\n /s, 'output is folded!');
done_testing;