Escape and unescape xml element names if necessary in ServerUtils.BuildXmlData() and ParseElement()

If AvatarService appearance data is retrieved over the network, then ServerUtils was attempting to transfer names such as "Wearable 0:0" directly to xml element names, resulting in an exception.
Space is not valid in xml element names.  Neither is : in this case since the intention is not to namespace.  Using names directly as keys is not a good idea.
To get around this problem this patch escapes and unescapes the element names as appropriate.
This has no impact on existing xml (since it had to be valid in the first place) but allows AvatarService data to be used over the network.
Setting appearance (from simulator to AvatarService) did not suffer this problem since the values are passed in the query string which is already properly escaped.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-05-09 20:52:54 +01:00
parent a896aac4bd
commit 2e1c2e1261
1 changed files with 3 additions and 3 deletions

View File

@ -265,7 +265,7 @@ namespace OpenSim.Server.Base
continue;
XmlElement elem = parent.OwnerDocument.CreateElement("",
kvp.Key, "");
XmlConvert.EncodeLocalName(kvp.Key), "");
if (kvp.Value is Dictionary<string, object>)
{
@ -320,11 +320,11 @@ namespace OpenSim.Server.Base
XmlNode type = part.Attributes.GetNamedItem("type");
if (type == null || type.Value != "List")
{
ret[part.Name] = part.InnerText;
ret[XmlConvert.DecodeName(part.Name)] = part.InnerText;
}
else
{
ret[part.Name] = ParseElement(part);
ret[XmlConvert.DecodeName(part.Name)] = ParseElement(part);
}
}