From 2e1c2e1261e58aa742a0c794acbce03df67ac9be Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 9 May 2012 20:52:54 +0100 Subject: [PATCH] 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. --- OpenSim/Server/Base/ServerUtils.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 8effdd2d1b..3d1b8c5017 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -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) { @@ -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); } }