-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Took me forever to find this since it violated some of my assumptions, like that if any header values handled UTF-8 correctly they all would :-).
UTF-8 in header string values works fine for Subject and To. However, if I pass a header string value for the header "X-Minicon-DB" that Encode::is_utf8() believes is UTF-8 (even if none of the characters are non-ASCII), an attempt to send an email with that header times out (with SMTP transport).
I finally demonstrated this by using Encode::encode() and Encode::decode() to force the two states; ASCII works consistently, UTF-8 hangs consistently.
The following code fragment creates a header array later used in Email::MIME->Create(); when that second line is a decode() call, sending the email created hangs with Sending failed: error at after DATA: 4.4.2 homiemail-a25.g.dreamhost.com Error: timeout exceeded. When it is an encode() call, sending the email succeeds. (This is descended from production code but rather simplified at this point.)
my $xmdb = '53 pr1 350141';
$xmdb = decode('UTF-8', $xmdb); # encode() sends okay, decode() hangs in SMTP transport later
print "xmdb \"$xmdb\" utf-8 ", is_utf8($xmdb)? 'y':'n', "\n";
my $header_str = [
'From' => "Minicon <empubs\@minicon$mcnum.mnstf.org>",
'To' => '"' . $topguy->{'name'} . '" <' . $destemail . '>',
'X-Minicon-DB' => $xmdb,
'Subject' => "Minicon $mcnum Progress Report 1",
];
Once I determined what was causing the hang (which probably took me longer than it should have; the fact that some headers with utf-8 values worked lead me to put off testing that as the cause until late, so I wasted time checking lots of other things that weren't the cause), it is of course easy to work around the problem, by using encode(). Still, this probably isn't the intended behavior, and if it is it should at least be documented clearly (or maybe I missed finding it).