Another attempt at parsing MOAP <Media> elements in OAR files.

Seems there are multiple interpretations of the format of the content of the
<Media> 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 <Media> element with regular XML.

This patch parses the <Media> escaped XML content as it always has and, if
the parsing fails, falls back to trying to parse the pure XML.
0.9.0-post-fixes
Robert Adams 2017-06-08 21:41:34 -07:00
parent 1e3a19e673
commit 5bfe8b18fe
1 changed files with 22 additions and 1 deletions

View File

@ -1361,7 +1361,28 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlReader reader) 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 &gt; 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); shp.Media = PrimitiveBaseShape.MediaList.FromXml(value);
} }