#122 Incorrect deserialization of arrays/vectors

0.65
closed-fixed
nobody
7
2007-10-02
2006-12-10
dwpoon
No

SOAP::Deserializer::decode_value() deserializes arrays/vectors incorrectly.

Around SOAP/Lite.pm line 2163 (version 0.69), the child elements are decoded. The first child with that element name is stored as a scalar, which is stuffed into a new arrayref if additional children with that element name are later encountered.

However, the logic for determining when to convert the scalar into an arrayref is faulty. If the scalar happens to already be an arrayref (that resulted from decoding an apachesoap:Vector, for example), the
elsif (ref $prev ne "ARRAY")
clause is never used, causing the following children to be incorrectly appended to the existing arrayref.

The solution is to keep track of how many children there are, instead of relying on the type of the child. See the attached patch.

Discussion

  • dwpoon
    dwpoon
    2006-12-10

    Logged In: YES
    user_id=1181585
    Originator: YES

    File Added: soap-lite-arraydeserialization-testcase

     
  • Siblin
    Siblin
    2007-03-02

    Logged In: YES
    user_id=1733266
    Originator: NO

    This patch fixed a problem we had with deserialization of arrays when several arrays exist in the SOAP response.

    The first array would contain the valid data, plus arrayref's for any element of other arrays. My suspicion was this was a parser problem, as the XML elements were always called "Array", however this patch seems to have sorted all of these problems...

    Many thanks!

     
  • Martin Kutter
    Martin Kutter
    2007-10-01

    • assigned_to: byrnereese --> nobody
    • status: open --> open-accepted
     
  • Martin Kutter
    Martin Kutter
    2007-10-01

    Logged In: YES
    user_id=884175
    Originator: NO

    This one is both important, and a patch is included. Should make it soon :-)

     
  • Martin Kutter
    Martin Kutter
    2007-10-01

    • priority: 5 --> 7
     
  • Martin Kutter
    Martin Kutter
    2007-10-02

    • status: open-accepted --> closed-fixed
     
  • Martin Kutter
    Martin Kutter
    2007-10-02

    Logged In: YES
    user_id=884175
    Originator: NO

    Applied in 1.43 in CVS.

    Thank you very much !

     
  • Martin Kutter
    Martin Kutter
    2007-10-08

    Logged In: YES
    user_id=884175
    Originator: NO

    Looks like it only made it into 1.52 in CVS. But now it's there, and a core test is there, too.