Subject: | MIME::Parser::parse_open incorrectly works with strawberryperl on Windows |
I use strawberryperl 5.10.1 on Windows XP and installed mime-tools 5.427
from CPAN.
I take the daemon.req MIME file (see attachment). It was produced by
Mozilla Firefox (but what is sent over HTTP is also MIME, isn't it?)
I has file 'aaa' inside with Content-Type: application/octet-stream. But
it is really a test file with Windows CRLF line endings.
Then I try to parse it with the following script:
-----------------------------------------------
my $file = "C:\\Temp\\mime\\daemon.req";
use MIME::Parser;
my $parser = MIME::Parser->new;
$parser->output_under("C:\\Temp\\mime");
$parser->parse_open($file);
-----------------------------------------------
The resulting file after parsing has UNIX line endings in it.
If I change the script:
-----------------------------------------------
my $file = "C:\\Temp\\mime\\daemon.req";
use MIME::Parser;
my $parser = MIME::Parser->new;
$parser->output_under("C:\\Temp\\mime");
open(FH, "<$file");
binmode FH;
$parser->parse(\*FH);
-----------------------------------------------
everything works fine.
I found this bug when I tried to parse file containing .mp3 attachment
and got broken file, so it is not as harmless as it looks with text files.
The following simple diff works for me in this case, but I am not sure
it is always correct (and did not test on Linux).
Subject: | daemon.req |
Message body not shown because it is not plain text.