From 5bfe8b18fe47012530231a614c9123372afb4c03 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 8 Jun 2017 21:41:34 -0700 Subject: [PATCH] Another attempt at parsing MOAP elements in OAR files. Seems there are multiple interpretations of the format of the content of the element in OAR files. OpenSimulator (for reasons lost in the mist of time) escapes the XML in the element and then reparses it was a separate XmlReader. Other simulators fill the element with regular XML. This patch parses the escaped XML content as it always has and, if the parsing fails, falls back to trying to parse the pure XML. --- .../Serialization/SceneObjectSerializer.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 892403ba49..aa15422e17 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1361,7 +1361,28 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlReader reader) { - string value = reader.ReadElementContentAsString("Media", String.Empty); + string value = String.Empty; + try + { + // The prominant format for MOAP is escaped XML (with > etc). + // This is read as a string and passed to PrimitiveBaseShape which requires + // its XML as a string (which it parses with its own XmlReader). + value = reader.ReadElementContentAsString("Media", String.Empty); + } + catch (XmlException e) + { + // There are versions of OAR files that contain unquoted XML. + try + { + m_log.WarnFormat("[SERIALIZER] MOAP specification in non-escaped XML format. Recovering."); + value = reader.ReadInnerXml(); + } + catch (Exception ee) + { + m_log.ErrorFormat("[SERIALIZER] Failed parsing of MOAP information"); + throw new XmlException("Failed parsing of MOAP media XML element"); + } + } shp.Media = PrimitiveBaseShape.MediaList.FromXml(value); }