.net xml things don't like null terminated strings
parent
9ecee558b5
commit
e308ab8843
|
@ -193,8 +193,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
coa = null;
|
coa = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
int len = data.Length;
|
||||||
|
if (len < 32)
|
||||||
|
return false;
|
||||||
|
if (data[len - 1] == 0)
|
||||||
|
--len;
|
||||||
// Quickly check if this is a coalesced object, without fully parsing the XML
|
// Quickly check if this is a coalesced object, without fully parsing the XML
|
||||||
using (MemoryStream ms = new MemoryStream(data))
|
using (MemoryStream ms = new MemoryStream(data, 0, len, false))
|
||||||
{
|
{
|
||||||
using (XmlTextReader reader = new XmlTextReader(ms))
|
using (XmlTextReader reader = new XmlTextReader(ms))
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
String fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData);
|
String fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData);
|
||||||
using (XmlTextReader wrappedReader = new XmlTextReader(fixedData, XmlNodeType.Element, null))
|
using (XmlTextReader wrappedReader = new XmlTextReader(fixedData, XmlNodeType.Element, null))
|
||||||
{
|
{
|
||||||
using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment}))
|
using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment }))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,31 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SceneObjectGroup FromOriginalXmlData(byte[] data)
|
||||||
|
{
|
||||||
|
int len = data.Length;
|
||||||
|
if(len < 32)
|
||||||
|
return null;
|
||||||
|
if(data[len -1 ] == 0)
|
||||||
|
--len;
|
||||||
|
using (MemoryStream ms = new MemoryStream(data,0, len, false))
|
||||||
|
{
|
||||||
|
using (XmlReader reader = XmlReader.Create(ms, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment }))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return FromOriginalXmlFormat(reader);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.Error("[SERIALIZER]: Deserialization of xml data failed ", e);
|
||||||
|
string s = Utils.BytesToString(data);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deserialize a scene object from the original xml format
|
/// Deserialize a scene object from the original xml format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -808,7 +808,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(Utils.BytesToString(sceneObjectAsset.Data));
|
SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlData(sceneObjectAsset.Data);
|
||||||
if (null != sog)
|
if (null != sog)
|
||||||
{
|
{
|
||||||
sog.TemporaryInstance = true;
|
sog.TemporaryInstance = true;
|
||||||
|
|
Loading…
Reference in New Issue