From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- .../Framework/Serialization/ArchiveConstants.cs | 4 +- .../External/ExternalRepresentationUtils.cs | 9 +++-- .../Serialization/External/LandDataSerializer.cs | 1 + .../Serialization/External/OspResolver.cs | 44 +++++++++++----------- .../External/RegionSettingsSerializer.cs | 35 ++++++++--------- .../External/UserInventoryItemSerializer.cs | 24 ++++++------ .../External/UserProfileSerializer.cs | 12 +++--- .../Serialization/Properties/AssemblyInfo.cs | 10 ++--- .../Framework/Serialization/TarArchiveWriter.cs | 12 +++--- 9 files changed, 78 insertions(+), 73 deletions(-) (limited to 'OpenSim/Framework/Serialization') diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index ab3c285..9081411 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs @@ -72,12 +72,12 @@ namespace OpenSim.Framework.Serialization /// Path for region settings. /// public const string SETTINGS_PATH = "settings/"; - + /// /// Path for region settings. /// public const string LANDDATA_PATH = "landdata/"; - + /// /// Path for user profiles /// diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index 55640ac..af130a5 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs @@ -106,13 +106,13 @@ namespace OpenSim.Framework.Serialization.External { errors = true; parseExceptionAction(nodeToFill, nodeName, e); - + if (xtr.EOF) { m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to unexpected end of XML"); break; } - + if (++numErrors == 10) { m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to too many parsing errors"); @@ -156,6 +156,7 @@ namespace OpenSim.Framework.Serialization.External return xml; XmlDocument doc = new XmlDocument(); + doc.XmlResolver=null; doc.LoadXml(xml); XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); @@ -220,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, ProhibitDtd = true})) { TransformXml(reader, writer, sceneName, homeURL, userService, scopeID); @@ -369,7 +370,7 @@ namespace OpenSim.Framework.Serialization.External break; case XmlNodeType.XmlDeclaration: - // For various reasons, not all serializations have xml declarations (or consistent ones) + // For various reasons, not all serializations have xml declarations (or consistent ones) // and as it's embedded inside a byte stream we don't need it anyway, so ignore. break; diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index e42d56f..33ffd83 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs @@ -178,6 +178,7 @@ namespace OpenSim.Framework.Serialization.External using (XmlTextReader reader = new XmlTextReader(new StringReader(serializedLandData))) { + reader.ProhibitDtd = true; reader.ReadStartElement("LandData"); ExternalRepresentationUtils.ExecuteReadProcessors(landData, m_ldProcessors, reader); diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs index fa7160f..a1e9d55 100644 --- a/OpenSim/Framework/Serialization/External/OspResolver.cs +++ b/OpenSim/Framework/Serialization/External/OspResolver.cs @@ -35,13 +35,13 @@ using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Serialization { /// - /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for + /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for /// identifying user profiles or supplying a simple name if no profile is available. /// public class OspResolver { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + public const string OSPA_PREFIX = "ospa:"; public const string OSPA_NAME_KEY = "n"; public const string OSPA_NAME_VALUE_SEPARATOR = " "; @@ -76,7 +76,7 @@ namespace OpenSim.Framework.Serialization return null; } - + /// /// Make an OSPA given a user name /// @@ -89,17 +89,17 @@ namespace OpenSim.Framework.Serialization // m_log.DebugFormat("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); // System.Console.WriteLine("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); - + return ospa; } - + /// /// Resolve an osp string into the most suitable internal OpenSim identifier. /// - /// + /// /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may /// just return the same identifier after creating a temporary profile. - /// + /// /// /// /// @@ -111,14 +111,14 @@ namespace OpenSim.Framework.Serialization if (!ospa.StartsWith(OSPA_PREFIX)) { // m_log.DebugFormat("[OSP RESOLVER]: ResolveOspa() got unrecognized format [{0}]", ospa); - return UUID.Zero; + return UUID.Zero; } // m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); - + string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); - + foreach (string tuple in ospaTuples) { int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR); @@ -128,17 +128,17 @@ namespace OpenSim.Framework.Serialization m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa); continue; } - + string key = tuple.Remove(tupleSeparatorIndex).Trim(); string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); - + if (OSPA_NAME_KEY == key) return ResolveOspaName(value, userService); } - + return UUID.Zero; } - + /// /// Hash a profile name into a UUID /// @@ -148,7 +148,7 @@ namespace OpenSim.Framework.Serialization { return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0); } - + /// /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile /// then a temporary user profile is inserted in the cache. @@ -164,13 +164,13 @@ namespace OpenSim.Framework.Serialization return UUID.Zero; int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); - + if (nameSeparatorIndex < 0) { m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name); return UUID.Zero; } - + string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); @@ -178,14 +178,14 @@ namespace OpenSim.Framework.Serialization if (account != null) { // m_log.DebugFormat( -// "[OSP RESOLVER]: Found user account with uuid {0} for {1} {2}", +// "[OSP RESOLVER]: Found user account with uuid {0} for {1} {2}", // account.PrincipalID, firstName, lastName); - + return account.PrincipalID; } // else // { -// m_log.DebugFormat("[OSP RESOLVER]: No resolved OSPA user account for {0}", name); +// m_log.DebugFormat("[OSP RESOLVER]: No resolved OSPA user account for {0}", name); // } // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc @@ -194,11 +194,11 @@ namespace OpenSim.Framework.Serialization tempUserProfile.FirstName = firstName; tempUserProfile.SurName = lastName; tempUserProfile.ID = HashName(tempUserProfile.Name); - + m_log.DebugFormat( "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); - + return tempUserProfile.ID; */ diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs index 19468c3..fd21f3e 100644 --- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs +++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs @@ -50,7 +50,7 @@ namespace OpenSim.Framework.Serialization.External { return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length)); } - + /// /// Deserialize settings /// @@ -60,14 +60,15 @@ namespace OpenSim.Framework.Serialization.External public static RegionSettings Deserialize(string serializedSettings) { RegionSettings settings = new RegionSettings(); - + StringReader sr = new StringReader(serializedSettings); XmlTextReader xtr = new XmlTextReader(sr); - + xtr.ProhibitDtd = true; + xtr.ReadStartElement("RegionSettings"); - + xtr.ReadStartElement("General"); - + while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) { switch (xtr.Name) @@ -113,10 +114,10 @@ namespace OpenSim.Framework.Serialization.External break; } } - + xtr.ReadEndElement(); xtr.ReadStartElement("GroundTextures"); - + while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) { switch (xtr.Name) @@ -159,10 +160,10 @@ namespace OpenSim.Framework.Serialization.External break; } } - + xtr.ReadEndElement(); xtr.ReadStartElement("Terrain"); - + while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) { switch (xtr.Name) @@ -212,19 +213,19 @@ namespace OpenSim.Framework.Serialization.External xtr.Close(); sr.Close(); - + return settings; } - + public static string Serialize(RegionSettings settings) { StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; xtw.WriteStartDocument(); - + xtw.WriteStartElement("RegionSettings"); - + xtw.WriteStartElement("General"); xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString()); xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString()); @@ -255,7 +256,7 @@ namespace OpenSim.Framework.Serialization.External xtw.WriteElementString("ElevationHighSE", settings.Elevation2SE.ToString()); xtw.WriteElementString("ElevationHighNE", settings.Elevation2NE.ToString()); xtw.WriteEndElement(); - + xtw.WriteStartElement("Terrain"); xtw.WriteElementString("WaterHeight", settings.WaterHeight.ToString()); xtw.WriteElementString("TerrainRaiseLimit", settings.TerrainRaiseLimit.ToString()); @@ -275,12 +276,12 @@ namespace OpenSim.Framework.Serialization.External xtw.WriteElementString("SpawnPoint", sp.ToString()); } xtw.WriteEndElement(); - + xtw.WriteEndElement(); - + xtw.Close(); sw.Close(); - + return sw.ToString(); } } diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index 994cede..12194ad 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs @@ -36,9 +36,9 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Services.Interfaces; - + namespace OpenSim.Framework.Serialization.External -{ +{ /// /// Serialize and deserialize user inventory items as an external format. /// @@ -49,14 +49,14 @@ namespace OpenSim.Framework.Serialization.External private static Dictionary> m_InventoryItemXmlProcessors = new Dictionary>(); - #region InventoryItemBase Processor initialization + #region InventoryItemBase Processor initialization static UserInventoryItemSerializer() { m_InventoryItemXmlProcessors.Add("Name", ProcessName); m_InventoryItemXmlProcessors.Add("ID", ProcessID); m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType); m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID); - m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID); + m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID); m_InventoryItemXmlProcessors.Add("CreatorData", ProcessCreatorData); m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate); m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner); @@ -73,7 +73,7 @@ namespace OpenSim.Framework.Serialization.External m_InventoryItemXmlProcessors.Add("GroupID", ProcessGroupID); m_InventoryItemXmlProcessors.Add("GroupOwned", ProcessGroupOwned); } - #endregion + #endregion #region InventoryItemBase Processors private static void ProcessName(InventoryItemBase item, XmlReader reader) @@ -189,7 +189,7 @@ namespace OpenSim.Framework.Serialization.External { return Deserialize(Encoding.ASCII.GetString(serialization, 0, serialization.Length)); } - + /// /// Deserialize settings /// @@ -202,6 +202,8 @@ namespace OpenSim.Framework.Serialization.External using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization))) { + reader.ProhibitDtd = true; + reader.ReadStartElement("InventoryItem"); ExternalRepresentationUtils.ExecuteReadProcessors( @@ -212,8 +214,8 @@ namespace OpenSim.Framework.Serialization.External //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID); return item; - } - + } + public static string Serialize(InventoryItemBase inventoryItem, Dictionary options, IUserAccountService userAccountService) { StringWriter sw = new StringWriter(); @@ -294,11 +296,11 @@ namespace OpenSim.Framework.Serialization.External } writer.WriteEndElement(); - + writer.Close(); sw.Close(); - + return sw.ToString(); - } + } } } diff --git a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs index c685a15..34eaa99 100644 --- a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs @@ -42,31 +42,31 @@ namespace OpenSim.Framework.Serialization.External { public const int MAJOR_VERSION = 0; public const int MINOR_VERSION = 1; - + public static string Serialize(UUID userID, string firstName, string lastName) { StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; xtw.WriteStartDocument(); - + xtw.WriteStartElement("user_profile"); xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString()); xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString()); - + xtw.WriteElementString("name", firstName + " " + lastName); xtw.WriteElementString("id", userID.ToString()); xtw.WriteElementString("about", ""); - + // Not sure if we're storing this yet, need to take a look // xtw.WriteElementString("Url", profile.Url); // or, indeed, interests xtw.WriteEndElement(); - + xtw.Close(); sw.Close(); - + return sw.ToString(); } } diff --git a/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs b/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs index acec20f..7dfb87b 100644 --- a/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Framework.Serialization")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Framework/Serialization/TarArchiveWriter.cs b/OpenSim/Framework/Serialization/TarArchiveWriter.cs index 2a3bc48..a5c3d0a 100644 --- a/OpenSim/Framework/Serialization/TarArchiveWriter.cs +++ b/OpenSim/Framework/Serialization/TarArchiveWriter.cs @@ -113,7 +113,7 @@ namespace OpenSim.Framework.Serialization lock (m_bw) { m_bw.Write(finalZeroPadding); - + m_bw.Flush(); m_bw.Close(); } @@ -149,7 +149,7 @@ namespace OpenSim.Framework.Serialization { // m_log.DebugFormat( // "[TAR ARCHIVE WRITER]: Data for {0} is {1} bytes", filePath, (null == data ? "null" : data.Length.ToString())); - + byte[] header = new byte[512]; // file path field (100) @@ -208,18 +208,18 @@ namespace OpenSim.Framework.Serialization { // Write out header m_bw.Write(header); - + // Write out data // An IOException occurs if we try to write out an empty array in Mono 2.6 if (data.Length > 0) m_bw.Write(data); - + if (data.Length % 512 != 0) { int paddingRequired = 512 - (data.Length % 512); - + //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired); - + byte[] padding = new byte[paddingRequired]; m_bw.Write(padding); } -- cgit v1.1