我在Perl中使用MIME :: Entity模塊創建MIME消息。某些標題似乎編碼正常,而其他標題似乎存在摺疊問題。MIME ::實體標題編碼正確嗎?
代碼:
use strict;
use Encode;
use MIME::Entity;
my %build_params = (
'Charset' => 'UTF-8',
'From' => encode('MIME-Header', 'Fantasy Email <[email protected]>'),
'Subject' => encode('MIME-Header', "A very long subject that will span on multiple lines in the headers, with a leading sp\
ace at the beginning of each new line."),
'Type' => 'multipart/alternative',
);
my $top = MIME::Entity->build(%build_params);
$top->print_header();
輸出:
Content-Type: multipart/alternative;
boundary="----------=_1312196104-11708-0";
charset="UTF-8"
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Subject: A very long subject that will span on multiple lines in the
headers, with a leading space at the beginning of each new line.
From: Fantasy Email
<[email protected] .com>
的Subject
似乎正確地分成多行。 From
沒有,在com
之前留下一個空格,但換行符不見了。
這是標準行爲還是我在MIME :: Entity中發現了一個錯誤?
看起來像一個bug給我。 '.com'之前的空間大部分都是。另外,如果您完全複製了*製作的內容,似乎會在'headers,'後添加一個新空格。 –
嗯,你說的是逗號後的雙倍空間。這一個顯然是一個錯誤。 – jeje
還要注意,添加的空間*可能*在兩個頭文件的相同位置,所以它可能是'MIME :: Entity'上的分割表達式中的一個錯誤。 –