This queue is for tickets about the SOAP-Lite CPAN distribution.

Report information
The Basics
Id:
45611
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
ZACKSE [...] cpan.org
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
0.710.08
Fixed in:
(no value)



Subject: [patch] deserializing SOAP message with composite attachment raises exception
The default MIME::Parser behavior is to extracted nested attachments, which breaks SOAP::Lite when handling a SOAP message with a composite attachment (e.g., an email). Trying to deserialize such a message causes an exception to be raised: Can't call method "as_string" on an undefined value at /path/to/SOAP/Lite.pm line 1985. This is because the code in SOAP::Deserializer::decode_parts() assumes the top-level MIME entity has a body (i.e., isn't nested). Attached is a patch that changes the default MIME::Parser to not extract nested attachments, along with a unit test that fails before and passes after applying this patch. Thanks for all the work on this library, it has been very useful.
Subject: soap_lite_attachment.patch
diff -ur SOAP-Lite-0.710.08-orig/lib/SOAP/Lite/Packager.pm SOAP-Lite-0.710.08-new/lib/SOAP/Lite/Packager.pm --- SOAP-Lite-0.710.08-orig/lib/SOAP/Lite/Packager.pm 2008-03-15 16:25:57.000000000 -0400 +++ SOAP-Lite-0.710.08-new/lib/SOAP/Lite/Packager.pm 2009-04-30 16:01:26.000000000 -0400 @@ -121,6 +121,7 @@ $self->{'_parser'}->output_to_core('ALL'); $self->{'_parser'}->tmp_to_core(1); $self->{'_parser'}->ignore_errors(1); + $self->{'_parser'}->extract_nested_messages(0); } sub generate_random_string { diff -ur SOAP-Lite-0.710.08-orig/lib/SOAP/Packager.pm SOAP-Lite-0.710.08-new/lib/SOAP/Packager.pm --- SOAP-Lite-0.710.08-orig/lib/SOAP/Packager.pm 2008-06-09 03:06:43.000000000 -0400 +++ SOAP-Lite-0.710.08-new/lib/SOAP/Packager.pm 2009-04-30 16:03:17.000000000 -0400 @@ -116,6 +116,7 @@ $self->{'_parser'}->output_to_core('ALL'); $self->{'_parser'}->tmp_to_core(1); $self->{'_parser'}->ignore_errors(1); + $self->{'_parser'}->extract_nested_messages(0); } sub generate_random_string { Only in SOAP-Lite-0.710.08-new: Makefile.old diff -ur SOAP-Lite-0.710.08-orig/t/04-attach.t SOAP-Lite-0.710.08-new/t/04-attach.t --- SOAP-Lite-0.710.08-orig/t/04-attach.t 2008-04-14 12:47:54.000000000 -0400 +++ SOAP-Lite-0.710.08-new/t/04-attach.t 2009-04-30 16:13:06.000000000 -0400 @@ -217,3 +217,72 @@ $a->valueof('//insurance_claim_auto')->{theSignedForm} =~ /TIFF/); ok(ref $a && $a->valueof('//theSignedForm') =~ /binary TIFF image/); } + +{ # check attachment of composite element + $soap = SOAP::Lite->new(); + $soap->init_context(); + + ############################################################################## + print "Attachment deserialization (Nested Attachment) test(s)...\n"; + $a = $soap->deserializer->deserialize(<<'EOX'); +Content-Type: Multipart/Related; boundary=MIME_boundary; type="text/xml"; start="<claimstart.xml@claiming-it.com>" +SOAPAction: http://schemas.risky-stuff.com/Auto-Claim +Content-Description: This is the optional message description. + +--MIME_boundary +Content-Type: text/xml; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Content-ID: <claimstart.xml@claiming-it.com> + +<?xml version='1.0' ?> +<soap:Envelope + xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <claim:insurance_claim_auto + id="insurance_claim_document_id" + xmlns:claim="http://schemas.risky-stuff.com/Auto-Claim"> + <email href="cid:email.eml@claiming-it.com" /> + </claim:insurance_claim_auto> + </soap:Body> +</soap:Envelope> + +--MIME_boundary +Content-Type: message/rfc822 +Content-Transfer-Encoding: binary +Content-ID: <email.eml@claiming-it.com> + +MIME-Version: 1.0 +X-Mailer: MIME::Lite 3.01 (F2.74; T1.24; A1.74; B3.07; Q3.07) +Date: Thu, 30 Apr 2009 15:59:49 -0400 +To: foo@bar.com +Subject: multipart message +Content-Transfer-Encoding: binary +Content-Type: multipart/related; boundary="_----------=_1241121589160890" + +This is a multi-part message in MIME format. + +--_----------=_1241121589160890 +Content-Disposition: inline +Content-Length: 36 +Content-Transfer-Encoding: binary +Content-Type: text/html + + <body>Here's <i>my</i> text</body> +--_----------=_1241121589160890 +Content-Disposition: inline +Content-Length: 16 +Content-Transfer-Encoding: binary +Content-Type: text/plain + + Here's my text +--_----------=_1241121589160890-- + +--MIME_boundary-- + +EOX + + ok(ref $a); + ok(ref $a && ref $a->valueof('//insurance_claim_auto') && + $a->valueof('//insurance_claim_auto')->{email} =~ m{my(</i>)? text}); + ok(ref $a && $a->valueof('//email') =~ m{my(</i>)? text}); +}
Thanks for the patch and test! Resolved in 0.716


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.