Fixed parsing of coalesced objects if the XML starts with an XML Declaration ("<xml ...>")
Resolves http://opensimulator.org/mantis/view.php?id=69440.8.0.3
parent
1a32b35279
commit
1769e93c42
|
@ -125,15 +125,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
// m_log.DebugFormat("[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() deserializing {0}", xml);
|
||||
|
||||
coa = null;
|
||||
int i = 0;
|
||||
|
||||
try
|
||||
{
|
||||
// Quickly check if this is a coalesced object, without fully parsing the XML
|
||||
using (StringReader sr = new StringReader(xml))
|
||||
{
|
||||
using (XmlTextReader reader = new XmlTextReader(sr))
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.Read();
|
||||
reader.MoveToContent(); // skip possible xml declaration
|
||||
|
||||
if (reader.Name != "CoalescedObject")
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
|
@ -142,18 +143,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(xml);
|
||||
XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
|
||||
if (e == null)
|
||||
return false;
|
||||
|
||||
coa = new CoalescedSceneObjects(UUID.Zero);
|
||||
reader.Read();
|
||||
|
||||
while (reader.NodeType != XmlNodeType.EndElement && reader.Name != "CoalescedObject")
|
||||
XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
|
||||
int i = 0;
|
||||
|
||||
foreach (XmlNode n in groups)
|
||||
{
|
||||
if (reader.Name == "SceneObjectGroup")
|
||||
{
|
||||
string soXml = reader.ReadOuterXml();
|
||||
|
||||
SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(soXml);
|
||||
|
||||
SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
|
||||
if (so != null)
|
||||
{
|
||||
coa.Add(so);
|
||||
|
@ -170,19 +176,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
reader.ReadEndElement(); // CoalescedObject
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[COALESCED SCENE OBJECTS SERIALIZER]: Deserialization of xml failed with {0} {1}",
|
||||
e.Message, e.StackTrace);
|
||||
m_log.Error(string.Format(
|
||||
"[COALESCED SCENE OBJECTS SERIALIZER]: Deserialization of xml failed with {0} ",
|
||||
e.Message), e);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue