a few more xml things

0.9.0.1-postfixes
UbitUmarov 2018-01-05 12:24:07 +00:00
parent 0b96cd56fc
commit 89a690c11f
20 changed files with 91 additions and 33 deletions

View File

@ -83,6 +83,9 @@ namespace OpenSim.Framework.Capabilities
{
using (XmlTextReader reader = new XmlTextReader(st))
{
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
reader.Read();
SkipWS(reader);

View File

@ -187,16 +187,18 @@ namespace OpenSim.Framework
if (text == String.Empty)
return null;
UTF8Encoding enc = new UTF8Encoding();
MemoryStream ms = new MemoryStream(enc.GetBytes(text));
XmlTextReader xreader = new XmlTextReader(ms);
PhysicsInertiaData v = new PhysicsInertiaData();
bool error;
PhysicsInertiaData v;
UTF8Encoding enc = new UTF8Encoding();
using(MemoryStream ms = new MemoryStream(enc.GetBytes(text)))
using(XmlTextReader xreader = new XmlTextReader(ms))
{
xreader.DtdProcessing = DtdProcessing.Prohibit;
xreader.XmlResolver = null;
v = new PhysicsInertiaData();
v.FromXml2(xreader, out error);
xreader.Close();
}
if (error)
return null;

View File

@ -1595,6 +1595,9 @@ namespace OpenSim.Framework
{
using (XmlTextReader xtr = new XmlTextReader(sr))
{
xtr.DtdProcessing = DtdProcessing.Prohibit;
xtr.XmlResolver = null;
xtr.MoveToContent();
string type = xtr.GetAttribute("type");

View File

@ -221,7 +221,7 @@ namespace OpenSim.Framework.Serialization.External
using (StringWriter sw = new StringWriter())
using (XmlTextWriter writer = new XmlTextWriter(sw))
using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, 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, DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null }))
{
TransformXml(reader, writer, sceneName, homeURL, userService, scopeID);

View File

@ -178,6 +178,8 @@ namespace OpenSim.Framework.Serialization.External
using (XmlTextReader reader = new XmlTextReader(new StringReader(serializedLandData)))
{
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
reader.ReadStartElement("LandData");
ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader);

View File

@ -63,6 +63,8 @@ namespace OpenSim.Framework.Serialization.External
StringReader sr = new StringReader(serializedSettings);
XmlTextReader xtr = new XmlTextReader(sr);
xtr.DtdProcessing = DtdProcessing.Prohibit;
xtr.XmlResolver = null;
xtr.ReadStartElement("RegionSettings");

View File

@ -202,6 +202,9 @@ namespace OpenSim.Framework.Serialization.External
using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization)))
{
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
reader.ReadStartElement("InventoryItem");
ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>(

View File

@ -54,6 +54,9 @@ namespace OpenSim.Framework.Servers.HttpServer
TRequest deserial;
using (XmlTextReader xmlReader = new XmlTextReader(request))
{
xmlReader.DtdProcessing = DtdProcessing.Prohibit;
xmlReader.XmlResolver = null;
XmlSerializer deserializer = new XmlSerializer(typeof (TRequest));
deserial = (TRequest) deserializer.Deserialize(xmlReader);
}

View File

@ -210,6 +210,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{
try
{
xmlReader.DtdProcessing = DtdProcessing.Prohibit;
xmlReader.XmlResolver = null;
XmlSerializer deserializer = new XmlSerializer(typeof(RestSessionObject<TRequest>));
deserial = (RestSessionObject<TRequest>)deserializer.Deserialize(xmlReader);
}
@ -269,6 +271,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{
try
{
xmlReader.DtdProcessing = DtdProcessing.Prohibit;
xmlReader.XmlResolver = null;
XmlSerializer deserializer = new XmlSerializer(typeof(TRequest));
deserial = (TRequest)deserializer.Deserialize(xmlReader);
}

View File

@ -124,6 +124,8 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
{
using(XmlTextReader sr = new XmlTextReader(s))
{
sr.DtdProcessing = DtdProcessing.Prohibit;
sr.XmlResolver = null;
sr.ReadStartElement("BakedAppearance");
while(sr.LocalName == "BakedTexture")
{

View File

@ -1130,6 +1130,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
XmlTextReader xtr = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);
xtr.DtdProcessing = DtdProcessing.Prohibit;
xtr.XmlResolver = null;
// Loaded metadata will be empty if no information exists in the archive
dearchivedScenes.LoadedCreationDateTime = 0;

View File

@ -93,6 +93,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
StringReader sr = new StringReader(xml);
XmlTextReader reader = new XmlTextReader(sr);
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
reader.ReadStartElement("assets");
reader.Read();

View File

@ -58,7 +58,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
using (XmlTextReader reader = new XmlTextReader(path))
{
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
XmlDocument doc = new XmlDocument();
doc.XmlResolver = null;
doc.Load(reader);
// if (doc.DocumentElement != null)
// {

View File

@ -593,6 +593,8 @@ namespace OpenSim.Region.Framework.Scenes
UTF8Encoding enc = new UTF8Encoding();
MemoryStream ms = new MemoryStream(enc.GetBytes(text));
XmlTextReader xreader = new XmlTextReader(ms);
xreader.DtdProcessing = DtdProcessing.Prohibit;
xreader.XmlResolver = null;
SOPVehicle v = new SOPVehicle();
bool error;

View File

@ -2389,7 +2389,7 @@ namespace OpenSim.Region.Framework.Scenes
{
using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, 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, DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null }))
{
reader.Read();
bool isSingleObject = reader.Name != "CoalescedObject";

View File

@ -133,6 +133,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
{
using (XmlTextReader reader = new XmlTextReader(sr))
{
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
reader.MoveToContent(); // skip possible xml declaration
if (reader.Name != "CoalescedObject")

View File

@ -63,7 +63,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
String fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData);
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, DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null }))
{
try
{
@ -267,18 +267,29 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
return null;
}
StringReader sr = new StringReader(parts[0].OuterXml);
XmlTextReader reader = new XmlTextReader(sr);
SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
reader.Close();
sr.Close();
SceneObjectGroup sceneObject;
using(StringReader sr = new StringReader(parts[0].OuterXml))
{
using(XmlTextReader reader = new XmlTextReader(sr))
{
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
}
}
// Then deal with the rest
SceneObjectPart part;
for (int i = 1; i < parts.Count; i++)
{
sr = new StringReader(parts[i].OuterXml);
reader = new XmlTextReader(sr);
SceneObjectPart part = SceneObjectPart.FromXml(reader);
using(StringReader sr = new StringReader(parts[i].OuterXml))
{
using(XmlTextReader reader = new XmlTextReader(sr))
{
part = SceneObjectPart.FromXml(reader);
}
}
int originalLinkNum = part.LinkNum;
@ -289,8 +300,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (originalLinkNum != 0)
part.LinkNum = originalLinkNum;
reader.Close();
sr.Close();
}
XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion");

View File

@ -49,14 +49,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
{
XmlDocument doc = new XmlDocument();
doc.XmlResolver=null;
XmlNode rootNode;
if (fileName.StartsWith("http:") || File.Exists(fileName))
{
XmlTextReader reader = new XmlTextReader(fileName);
using(XmlTextReader reader = new XmlTextReader(fileName))
{
reader.WhitespaceHandling = WhitespaceHandling.None;
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
doc.Load(reader);
reader.Close();
}
rootNode = doc.FirstChild;
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
{

View File

@ -196,13 +196,15 @@ namespace OpenSim.Region.Framework.Scenes
// ITerrainChannel.LoadFromXmlString()
public void LoadFromXmlString(string data)
{
StringReader sr = new StringReader(data);
XmlTextReader reader = new XmlTextReader(sr);
reader.Read();
using(StringReader sr = new StringReader(data))
{
using(XmlTextReader reader = new XmlTextReader(sr))
{
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
ReadXml(reader);
reader.Close();
sr.Close();
}
}
}
// ITerrainChannel.Merge

View File

@ -1125,6 +1125,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
return null;
doc = new XmlDocument();
doc.XmlResolver = null;
// Let's serialize all calls to Vivox. Most of these are driven by
// the clients (CAPs), when the user arrives at the region. We don't
@ -1146,8 +1147,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse())
using (Stream s = rsp.GetResponseStream())
using (XmlTextReader rdr = new XmlTextReader(s))
{
rdr.DtdProcessing = DtdProcessing.Prohibit;
rdr.XmlResolver = null;
doc.Load(rdr);
}
}
catch (Exception e)
{
m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message);