Subject: | Boundary delimiter in MIME::Entity |
RFC1521 says "\r\n" should be used as boundary delimiter, while MIME::Entity 5.417 has hardcoded "\n". This difference is crucial for some software: SOAP::Lite 0.60 requires MIME::Parser 6.106 because of its ability to locally set $MIME::Entity::BOUNDARY_DELIMITER. Please see the attached patch, which is basically a backport of this feature from MIME-tools-6.200_02 (it also gives basic explanation about SOAP::Lite).
--
Alexey Tourbin
ALT Linux Team
SOAP-Lite-0.60/Makefile.PL:
["MIME interoperability w/ Axis","SOAP::Lite",{"MIME::Parser" => "6.106"},0],
SOAP-Lite-0.60/lib/SOAP/Lite.pm:
# removed requirement for MIME::Parser 6.106
# even though it fixes interoperability problem with Axis, this version
# is still marked as "experimantal" on CPAN and is not available for
# auto-install (as of 08/08/03) --PK
# Exporter::require_version('MIME::Parser' => 6.106);
require MIME::Entity;
local $MIME::Entity::BOUNDARY_DELIMITER = "\r\n";
--- MIME-tools-5.417/lib/MIME/Entity.pm- 2005-01-13 19:23:15 +0000
+++ MIME-tools-5.417/lib/MIME/Entity.pm 2005-05-12 13:26:59 +0000
@@ -214,6 +214,27 @@ Debug:
=head1 PUBLIC INTERFACE
+
+=head2 Globals
+
+=over 4
+
+=item $BOUNDARY_DELIMITER
+
+This is the end-of-line sequence output at the end of a
+multipart boundary when you're printing a MIME::Entity.
+It defaults to "\n".
+I strongly suggest that you local'ize your overrides if possible:
+
+ sub do_stuff {
+ local $MIME::Entity::BOUNDARY_DELIMITER = "\r\n";
+ ...
+ $entity->print;
+ }
+
+
+=back
+
=cut
#------------------------------
@@ -251,6 +272,10 @@ use IO::Lines;
### The package version, both in 1.23 style *and* usable by MakeMaker:
$VERSION = "5.417";
+### Boundary end-of-line sequence:
+use vars qw($BOUNDARY_DELIMITER);
+$BOUNDARY_DELIMITER = "\n";
+
### Boundary counter:
my $BCount = 0;
@@ -1746,7 +1771,7 @@ sub print {
$out = wraphandle($out); ### get a printable output
$self->print_header($out); ### the header
- $out->print("\n");
+ $out->print($BOUNDARY_DELIMITER);
$self->print_body($out); ### the "stuff after the header"
}
@@ -1794,22 +1819,24 @@ sub print_body {
### Preamble:
my $preamble = join('', @{ $self->preamble || $DefPreamble });
- $out->print("$preamble\n") if ($preamble ne '');
+ $out->print($preamble.$BOUNDARY_DELIMITER)
+ if ($preamble ne '');
### Parts:
my $part;
foreach $part ($self->parts) {
- $out->print("--$boundary\n");
+ $out->print("--$boundary".$BOUNDARY_DELIMITER);
$part->print($out);
- $out->print("\n"); ### needed for next delim/close
+ $out->print($BOUNDARY_DELIMITER); ### needed for next delim/close
}
- $out->print("--$boundary--\n");
+ $out->print("--$boundary--".$BOUNDARY_DELIMITER);
### Epilogue:
my $epilogue = join('', @{ $self->epilogue || $DefEpilogue });
if ($epilogue ne '') {
$out->print($epilogue);
- $out->print("\n") if ($epilogue !~ /\n\Z/); ### be nice
+ $out->print($BOUNDARY_DELIMITER)
+ if ($epilogue !~ /\n\Z/); ### be nice
}
}