Subject: | RPC handling of arrays incorrect |
The first issue is in the Net::Jabber::Protocol::RPCParse_Array method.
This method looped through <data> nodes but the schema definition only
allows 1 <data> node. This method needs to loop through all the <value>
nodes that are children of the <data> node.
The second issue is in the Net::Jabber::Protocol::RPCEncode_Value method.
This method does not encode arrays correctly. This method tried to add
a <data> node for every element in the array. There should only be I
<data> node and the loop should just add <value> nodes.
See the attached patch file which resolves both of these issues.
The schema definition from jabber.org defines the "data" element without
any min or max boundaries so this means that there must be 1 and only 1
"data" element.
<xs:complexType name="ArrayType">
<xs:sequence>
<xs:element name="data">
<xs:complexType>
<xs:sequence>
<xs:element name="value" type="ValueType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
Subject: | Protocol.patch |
--- Copy of Protocol.pm 2004-08-17 01:30:24.000000000 -0400
+++ Protocol.pm 2006-03-08 16:24:34.929970500 -0500
@@ -2230,10 +2230,11 @@
if (ref($value) eq "ARRAY")
{
- my $array = $obj->AddValue()->AddArray();
+ my $array = $obj->AddValue()->AddArray()->AddData();
+
foreach my $data (@{$value})
{
- $self->RPCEncode_Value($array->AddData(),$data);
+ $self->RPCEncode_Value($array,$data);
}
}
elsif (ref($value) eq "HASH")
@@ -2378,9 +2379,9 @@
my($array) = @_;
my @array;
- foreach my $data ($array->GetDatas())
- {
- push(@array,$self->RPCParse_Value($data->GetValue()));
+
+ foreach my $value ($array->GetDatas()->GetValue()) {
+ push(@array,$self->RPCParse_Value($value));
}
return @array;