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)) using (XmlTextReader reader = new XmlTextReader(st))
{ {
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
reader.Read(); reader.Read();
SkipWS(reader); SkipWS(reader);

View File

@ -187,16 +187,18 @@ namespace OpenSim.Framework
if (text == String.Empty) if (text == String.Empty)
return null; return null;
UTF8Encoding enc = new UTF8Encoding();
MemoryStream ms = new MemoryStream(enc.GetBytes(text));
XmlTextReader xreader = new XmlTextReader(ms);
PhysicsInertiaData v = new PhysicsInertiaData();
bool error; 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.FromXml2(xreader, out error); v = new PhysicsInertiaData();
v.FromXml2(xreader, out error);
xreader.Close(); }
if (error) if (error)
return null; return null;

View File

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

View File

@ -221,7 +221,7 @@ namespace OpenSim.Framework.Serialization.External
using (StringWriter sw = new StringWriter()) using (StringWriter sw = new StringWriter())
using (XmlTextWriter writer = new XmlTextWriter(sw)) using (XmlTextWriter writer = new XmlTextWriter(sw))
using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) 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); 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))) using (XmlTextReader reader = new XmlTextReader(new StringReader(serializedLandData)))
{ {
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
reader.ReadStartElement("LandData"); reader.ReadStartElement("LandData");
ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader); ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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, DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null }))
{ {
try try
{ {
@ -267,18 +267,29 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
return null; return null;
} }
StringReader sr = new StringReader(parts[0].OuterXml); SceneObjectGroup sceneObject;
XmlTextReader reader = new XmlTextReader(sr); using(StringReader sr = new StringReader(parts[0].OuterXml))
SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader)); {
reader.Close(); using(XmlTextReader reader = new XmlTextReader(sr))
sr.Close(); {
reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
}
}
// Then deal with the rest // Then deal with the rest
SceneObjectPart part;
for (int i = 1; i < parts.Count; i++) for (int i = 1; i < parts.Count; i++)
{ {
sr = new StringReader(parts[i].OuterXml); using(StringReader sr = new StringReader(parts[i].OuterXml))
reader = new XmlTextReader(sr); {
SceneObjectPart part = SceneObjectPart.FromXml(reader); using(XmlTextReader reader = new XmlTextReader(sr))
{
part = SceneObjectPart.FromXml(reader);
}
}
int originalLinkNum = part.LinkNum; int originalLinkNum = part.LinkNum;
@ -289,8 +300,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (originalLinkNum != 0) if (originalLinkNum != 0)
part.LinkNum = originalLinkNum; part.LinkNum = originalLinkNum;
reader.Close();
sr.Close();
} }
XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion"); 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) public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
doc.XmlResolver=null;
XmlNode rootNode; XmlNode rootNode;
if (fileName.StartsWith("http:") || File.Exists(fileName)) if (fileName.StartsWith("http:") || File.Exists(fileName))
{ {
XmlTextReader reader = new XmlTextReader(fileName); using(XmlTextReader reader = new XmlTextReader(fileName))
reader.WhitespaceHandling = WhitespaceHandling.None; {
doc.Load(reader); reader.WhitespaceHandling = WhitespaceHandling.None;
reader.Close(); reader.DtdProcessing = DtdProcessing.Prohibit;
reader.XmlResolver = null;
doc.Load(reader);
}
rootNode = doc.FirstChild; rootNode = doc.FirstChild;
foreach (XmlNode aPrimNode in rootNode.ChildNodes) foreach (XmlNode aPrimNode in rootNode.ChildNodes)
{ {

View File

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

View File

@ -1125,6 +1125,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
return null; return null;
doc = new XmlDocument(); doc = new XmlDocument();
doc.XmlResolver = null;
// Let's serialize all calls to Vivox. Most of these are driven by // 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 // the clients (CAPs), when the user arrives at the region. We don't
@ -1146,7 +1147,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse())
using (Stream s = rsp.GetResponseStream()) using (Stream s = rsp.GetResponseStream())
using (XmlTextReader rdr = new XmlTextReader(s)) using (XmlTextReader rdr = new XmlTextReader(s))
doc.Load(rdr); {
rdr.DtdProcessing = DtdProcessing.Prohibit;
rdr.XmlResolver = null;
doc.Load(rdr);
}
} }
catch (Exception e) catch (Exception e)
{ {