]> OCCT Git - occt.git/commitdiff
0030066: Data Exchange - Fail to load VRML from ArcGIS
authorichesnok <ichesnok@opencascade.com>
Mon, 27 Mar 2023 08:37:44 +0000 (09:37 +0100)
committervglukhik <vglukhik@opencascade.com>
Wed, 17 May 2023 20:47:01 +0000 (21:47 +0100)
Fixed VrmlData_Scene::readHeader method

src/VrmlData/VrmlData_Scene.cxx
tests/bugs/stlvrml/bug30066 [new file with mode: 0644]

index 1c851aab428ec64275df11cba3156b13a2da125e..a263c23bbdf493bf025c589c090d1f6ba4447fe2 100644 (file)
@@ -314,12 +314,23 @@ VrmlData_ErrorStatus VrmlData_Scene::ReadLine (VrmlData_InBuffer& theBuffer)
 
 VrmlData_ErrorStatus VrmlData_Scene::readHeader (VrmlData_InBuffer& theBuffer)
 {
-  VrmlData_ErrorStatus aStat = readLine (theBuffer);
-  if (aStat == VrmlData_StatusOK &&
-      !VRMLDATA_LCOMPARE(theBuffer.LinePtr, "#VRML V2.0"))
-    aStat = VrmlData_NotVrmlFile;
-  else 
+  VrmlData_ErrorStatus aStat = readLine(theBuffer);
+  if (aStat != VrmlData_StatusOK)
+  {
+    return VrmlData_NotVrmlFile;
+  }
+  TCollection_AsciiString aHeader(theBuffer.LinePtr);
+  // The max possible header size is 25 (with spaces)
+  // 4 (max BOM size) + 11 (search string) + 9 (max size for encoding)
+  if (aHeader.Length() <= 25 &&
+      aHeader.Search("#VRML V2.0") != -1)
+  {
     aStat = readLine(theBuffer);
+  }
+  else
+  {
+    aStat = VrmlData_NotVrmlFile;
+  }
   return aStat;
 }
 
diff --git a/tests/bugs/stlvrml/bug30066 b/tests/bugs/stlvrml/bug30066
new file mode 100644 (file)
index 0000000..95aac17
--- /dev/null
@@ -0,0 +1,6 @@
+puts "========"
+puts "0030066: Data Exchange - Fail to load VRML from ArcGIS"
+puts "========"
+puts ""
+
+loadvrml sh [locate_data_file bug30066.wrl]
\ No newline at end of file