diff options
-rw-r--r-- | OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | 133 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 34 |
2 files changed, 155 insertions, 12 deletions
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index d5b585a..9c8c4d5 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -148,6 +148,113 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
148 | <OtherParts /> | 148 | <OtherParts /> |
149 | </SceneObjectGroup>"; | 149 | </SceneObjectGroup>"; |
150 | 150 | ||
151 | private string badFloatsXml = @" | ||
152 | <SceneObjectGroup> | ||
153 | <RootPart> | ||
154 | <SceneObjectPart xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> | ||
155 | <AllowedDrop>false</AllowedDrop> | ||
156 | <CreatorID><Guid>a6dacf01-4636-4bb9-8a97-30609438af9d</Guid></CreatorID> | ||
157 | <FolderID><Guid>e6a5a05e-e8cc-4816-8701-04165e335790</Guid></FolderID> | ||
158 | <InventorySerial>1</InventorySerial> | ||
159 | <TaskInventory /> | ||
160 | <ObjectFlags>0</ObjectFlags> | ||
161 | <UUID><Guid>e6a5a05e-e8cc-4816-8701-04165e335790</Guid></UUID> | ||
162 | <LocalId>2698615125</LocalId> | ||
163 | <Name>NaughtyPrim</Name> | ||
164 | <Material>0</Material> | ||
165 | <PassTouches>false</PassTouches> | ||
166 | <RegionHandle>1099511628032000</RegionHandle> | ||
167 | <ScriptAccessPin>0</ScriptAccessPin> | ||
168 | <GroupPosition><X>147.23</X><Y>92.698</Y><Z>22.78084</Z></GroupPosition> | ||
169 | <OffsetPosition><X>0</X><Y>0</Y><Z>0</Z></OffsetPosition> | ||
170 | <RotationOffset><X>-4.371139E-08</X><Y>-1</Y><Z>-4.371139E-08</Z><W>0</W></RotationOffset> | ||
171 | <Velocity><X>0</X><Y>0</Y><Z>0</Z></Velocity> | ||
172 | <RotationalVelocity><X>0</X><Y>0</Y><Z>0</Z></RotationalVelocity> | ||
173 | <AngularVelocity><X>0</X><Y>0</Y><Z>0</Z></AngularVelocity> | ||
174 | <Acceleration><X>0</X><Y>0</Y><Z>0</Z></Acceleration> | ||
175 | <Description /> | ||
176 | <Color /> | ||
177 | <Text /> | ||
178 | <SitName /> | ||
179 | <TouchName /> | ||
180 | <LinkNum>0</LinkNum> | ||
181 | <ClickAction>0</ClickAction> | ||
182 | <Shape> | ||
183 | <ProfileCurve>1</ProfileCurve> | ||
184 | <TextureEntry>AAAAAAAAERGZmQAAAAAABQCVlZUAAAAAQEAAAABAQAAAAAAAAAAAAAAAAAAAAA==</TextureEntry> | ||
185 | <ExtraParams>AA==</ExtraParams> | ||
186 | <PathBegin>0</PathBegin> | ||
187 | <PathCurve>16</PathCurve> | ||
188 | <PathEnd>0</PathEnd> | ||
189 | <PathRadiusOffset>0</PathRadiusOffset> | ||
190 | <PathRevolutions>0</PathRevolutions> | ||
191 | <PathScaleX>100</PathScaleX> | ||
192 | <PathScaleY>100</PathScaleY> | ||
193 | <PathShearX>0</PathShearX> | ||
194 | <PathShearY>0</PathShearY> | ||
195 | <PathSkew>0</PathSkew> | ||
196 | <PathTaperX>0</PathTaperX> | ||
197 | <PathTaperY>0</PathTaperY> | ||
198 | <PathTwist>0</PathTwist> | ||
199 | <PathTwistBegin>0</PathTwistBegin> | ||
200 | <PCode>9</PCode> | ||
201 | <ProfileBegin>0</ProfileBegin> | ||
202 | <ProfileEnd>0</ProfileEnd> | ||
203 | <ProfileHollow>0</ProfileHollow> | ||
204 | <Scale><X>10</X><Y>10</Y><Z>0.5</Z></Scale> | ||
205 | <State>0</State> | ||
206 | <ProfileShape>Square</ProfileShape> | ||
207 | <HollowShape>Same</HollowShape> | ||
208 | <SculptTexture><Guid>00000000-0000-0000-0000-000000000000</Guid></SculptTexture> | ||
209 | <SculptType>0</SculptType><SculptData /> | ||
210 | <FlexiSoftness>0</FlexiSoftness> | ||
211 | <FlexiTension>0,5</FlexiTension> | ||
212 | <FlexiDrag>yo mamma</FlexiDrag> | ||
213 | <FlexiGravity>0</FlexiGravity> | ||
214 | <FlexiWind>0</FlexiWind> | ||
215 | <FlexiForceX>0</FlexiForceX> | ||
216 | <FlexiForceY>0</FlexiForceY> | ||
217 | <FlexiForceZ>0</FlexiForceZ> | ||
218 | <LightColorR>0</LightColorR> | ||
219 | <LightColorG>0</LightColorG> | ||
220 | <LightColorB>0</LightColorB> | ||
221 | <LightColorA>1</LightColorA> | ||
222 | <LightRadius>0</LightRadius> | ||
223 | <LightCutoff>0</LightCutoff> | ||
224 | <LightFalloff>0</LightFalloff> | ||
225 | <LightIntensity>1</LightIntensity> | ||
226 | <FlexiEntry>false</FlexiEntry> | ||
227 | <LightEntry>false</LightEntry> | ||
228 | <SculptEntry>false</SculptEntry> | ||
229 | </Shape> | ||
230 | <Scale><X>10</X><Y>10</Y><Z>0.5</Z></Scale> | ||
231 | <UpdateFlag>0</UpdateFlag> | ||
232 | <SitTargetOrientation><X>0</X><Y>0</Y><Z>0</Z><W>1</W></SitTargetOrientation> | ||
233 | <SitTargetPosition><X>0</X><Y>0</Y><Z>0</Z></SitTargetPosition> | ||
234 | <SitTargetPositionLL><X>0</X><Y>0</Y><Z>0</Z></SitTargetPositionLL> | ||
235 | <SitTargetOrientationLL><X>0</X><Y>0</Y><Z>0</Z><W>1</W></SitTargetOrientationLL> | ||
236 | <ParentID>0</ParentID> | ||
237 | <CreationDate>1211330445</CreationDate> | ||
238 | <Category>0</Category> | ||
239 | <SalePrice>0</SalePrice> | ||
240 | <ObjectSaleType>0</ObjectSaleType> | ||
241 | <OwnershipCost>0</OwnershipCost> | ||
242 | <GroupID><Guid>00000000-0000-0000-0000-000000000000</Guid></GroupID> | ||
243 | <OwnerID><Guid>a6dacf01-4636-4bb9-8a97-30609438af9d</Guid></OwnerID> | ||
244 | <LastOwnerID><Guid>a6dacf01-4636-4bb9-8a97-30609438af9d</Guid></LastOwnerID> | ||
245 | <BaseMask>2147483647</BaseMask> | ||
246 | <OwnerMask>2147483647</OwnerMask> | ||
247 | <GroupMask>0</GroupMask> | ||
248 | <EveryoneMask>0</EveryoneMask> | ||
249 | <NextOwnerMask>2147483647</NextOwnerMask> | ||
250 | <Flags>None</Flags> | ||
251 | <CollisionSound><Guid>00000000-0000-0000-0000-000000000000</Guid></CollisionSound> | ||
252 | <CollisionSoundVolume>0</CollisionSoundVolume> | ||
253 | </SceneObjectPart> | ||
254 | </RootPart> | ||
255 | <OtherParts /> | ||
256 | </SceneObjectGroup>"; | ||
257 | |||
151 | private string xml2 = @" | 258 | private string xml2 = @" |
152 | <SceneObjectGroup> | 259 | <SceneObjectGroup> |
153 | <SceneObjectPart xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> | 260 | <SceneObjectPart xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> |
@@ -257,6 +364,32 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
257 | } | 364 | } |
258 | 365 | ||
259 | [Test] | 366 | [Test] |
367 | public void TestDeserializeBadFloatsXml() | ||
368 | { | ||
369 | TestHelpers.InMethod(); | ||
370 | log4net.Config.XmlConfigurator.Configure(); | ||
371 | |||
372 | SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(badFloatsXml); | ||
373 | SceneObjectPart rootPart = so.RootPart; | ||
374 | |||
375 | Assert.That(rootPart.UUID, Is.EqualTo(new UUID("e6a5a05e-e8cc-4816-8701-04165e335790"))); | ||
376 | Assert.That(rootPart.CreatorID, Is.EqualTo(new UUID("a6dacf01-4636-4bb9-8a97-30609438af9d"))); | ||
377 | Assert.That(rootPart.Name, Is.EqualTo("NaughtyPrim")); | ||
378 | |||
379 | // This terminates the deserialization earlier if couldn't be parsed. | ||
380 | // TODO: Need to address this | ||
381 | Assert.That(rootPart.GroupPosition.X, Is.EqualTo(147.23f)); | ||
382 | |||
383 | Assert.That(rootPart.Shape.PathCurve, Is.EqualTo(16)); | ||
384 | |||
385 | // Defaults for bad parses | ||
386 | Assert.That(rootPart.Shape.FlexiTension, Is.EqualTo(0)); | ||
387 | Assert.That(rootPart.Shape.FlexiDrag, Is.EqualTo(0)); | ||
388 | |||
389 | // TODO: Check other properties | ||
390 | } | ||
391 | |||
392 | [Test] | ||
260 | public void TestSerializeXml() | 393 | public void TestSerializeXml() |
261 | { | 394 | { |
262 | TestHelpers.InMethod(); | 395 | TestHelpers.InMethod(); |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 0a32214..e6b88a3 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Drawing; | 30 | using System.Drawing; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Linq; | ||
32 | using System.Reflection; | 33 | using System.Reflection; |
33 | using System.Xml; | 34 | using System.Xml; |
34 | using log4net; | 35 | using log4net; |
@@ -570,13 +571,15 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
570 | 571 | ||
571 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | 572 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) |
572 | { | 573 | { |
573 | bool errors = false; | 574 | List<string> errorNodeNames; |
574 | obj.Shape = ReadShape(reader, "Shape", out errors); | 575 | obj.Shape = ReadShape(reader, "Shape", out errorNodeNames); |
575 | 576 | ||
576 | if (errors) | 577 | if (errorNodeNames != null) |
578 | { | ||
577 | m_log.DebugFormat( | 579 | m_log.DebugFormat( |
578 | "[SceneObjectSerializer]: Parsing PrimitiveBaseShape for object part {0} {1} encountered errors. Please see earlier log entries.", | 580 | "[SceneObjectSerializer]: Parsing PrimitiveBaseShape for object part {0} {1} encountered errors in properties {2}.", |
579 | obj.Name, obj.UUID); | 581 | obj.Name, obj.UUID, string.Join(", ", errorNodeNames.ToArray())); |
582 | } | ||
580 | } | 583 | } |
581 | 584 | ||
582 | private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) | 585 | private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) |
@@ -1519,37 +1522,44 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1519 | /// </summary> | 1522 | /// </summary> |
1520 | /// <param name="reader"></param> | 1523 | /// <param name="reader"></param> |
1521 | /// <param name="name">The name of the xml element containing the shape</param> | 1524 | /// <param name="name">The name of the xml element containing the shape</param> |
1522 | /// <param name="errors">true if any errors were encountered during parsing, false otherwise</param> | 1525 | /// <param name="errors">a list containing the failing node names. If no failures then null.</param> |
1523 | /// <returns>The shape parsed</returns> | 1526 | /// <returns>The shape parsed</returns> |
1524 | public static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name, out bool errors) | 1527 | public static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name, out List<string> errorNodeNames) |
1525 | { | 1528 | { |
1526 | errors = false; | 1529 | List<string> internalErrorNodeNames = null; |
1527 | 1530 | ||
1528 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | 1531 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); |
1529 | 1532 | ||
1530 | if (reader.IsEmptyElement) | 1533 | if (reader.IsEmptyElement) |
1531 | { | 1534 | { |
1532 | reader.Read(); | 1535 | reader.Read(); |
1536 | errorNodeNames = null; | ||
1533 | return shape; | 1537 | return shape; |
1534 | } | 1538 | } |
1535 | 1539 | ||
1536 | reader.ReadStartElement(name, String.Empty); // Shape | 1540 | reader.ReadStartElement(name, String.Empty); // Shape |
1537 | 1541 | ||
1538 | errors = ExternalRepresentationUtils.ExecuteReadProcessors( | 1542 | ExternalRepresentationUtils.ExecuteReadProcessors( |
1539 | shape, | 1543 | shape, |
1540 | m_ShapeXmlProcessors, | 1544 | m_ShapeXmlProcessors, |
1541 | reader, | 1545 | reader, |
1542 | (o, nodeName, e) | 1546 | (o, nodeName, e) |
1543 | => | 1547 | => |
1544 | { | 1548 | { |
1545 | m_log.DebugFormat( | 1549 | // m_log.DebugFormat( |
1546 | "[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}", | 1550 | // "[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}", |
1547 | nodeName, e.Message, e.StackTrace); | 1551 | // nodeName, e.Message, e.StackTrace); |
1552 | if (internalErrorNodeNames == null) | ||
1553 | internalErrorNodeNames = new List<string>(); | ||
1554 | |||
1555 | internalErrorNodeNames.Add(nodeName); | ||
1548 | } | 1556 | } |
1549 | ); | 1557 | ); |
1550 | 1558 | ||
1551 | reader.ReadEndElement(); // Shape | 1559 | reader.ReadEndElement(); // Shape |
1552 | 1560 | ||
1561 | errorNodeNames = internalErrorNodeNames; | ||
1562 | |||
1553 | return shape; | 1563 | return shape; |
1554 | } | 1564 | } |
1555 | 1565 | ||