Loading ...
Sorry, an error occurred while loading the content.

2676MIME CRLF interop bug with Axis...

Expand Messages
  • Byrne Reese
    Jun 2, 2003
    • 0 Attachment
      I wanted to post a patch to MIME::Entity which will resolve a long
      standing interop bug between SOAP::Lite and Apache Axis. The problem
      will be resolved permanently in the next SOAP::Lite/SOAP::MIME release
      (so stay tuned).

      [With any luck, this patch will actually be made to MIME::Entity - and
      I working with the author of that toolkit to get it patched.]

      In summary, the problem has to do with MIME::Entity's use of newline
      characters exclusively as mime boundary delimitation -- when in fact
      it should CRLFs. The fix is to MIME::Entity::print_body. If you need
      to be interacting with Apache Axis services ASAP - add this to your
      perl scripts:

      BEGIN {

      sub MIME::Entity::print_body {
      my ($self, $out) = @_;
      $out = MIME::Entity::wraphandle($out || select); ### get a
      printable output
      my ($type) = split '/', lc($self->mime_type); ### handle by MIME type

      ### Multipart...
      if ($type eq 'multipart') {
      my $boundary = $self->head->multipart_boundary;

      ### Preamble:
      my $preamble = join('', @{ $self->preamble || $DefPreamble });
      $out->print("$preamble\n") if ($preamble ne '');

      ### Parts:
      my $part;
      foreach $part ($self->parts) {
      # PATCHED!!!!! Added the '\r'
      $out->print("--$boundary\r\n");
      $part->print($out);
      # PATCHED!!!!! Added the '\r'
      $out->print("\r\n"); ### needed for next delim/close
      }
      # PATCHED!!!!! Added the '\r'
      $out->print("--$boundary--\r\n");

      ### Epilogue:
      my $epilogue = join('', @{ $self->epilogue || $DefEpilogue });
      if ($epilogue ne '') {
      $out->print($epilogue);
      # PATCHED!!!!! Added the '\r'
      $out->print("\n") if ($epilogue !~ /\n\Z/); ### be nice
      }
      }

      ### Singlepart type with parts...
      ### This makes $ent->print handle message/rfc822 bodies
      ### when parse_nested_messages('NEST') is on [idea by Marc
      Rouleau].
      elsif ($self->parts) {
      my $need_sep = 0;
      my $part;
      foreach $part ($self->parts) {
      $out->print("\n\n") if $need_sep++;
      $part->print($out);
      }
      }

      ### Singlepart type, or no parts: output body...
      else {
      $self->bodyhandle ? $self->print_bodyhandle($out)
      : MIME::Entity::whine "missing body; treated as empty";
      }
      1;
      }
      }
    • Show all 2 messages in this topic