1) Add protection against accessing null pointer in PCDM_ReadWriter::FileFormat.
2) In LDOM_XmlReader::ReadRecord, take into account that the character '>' can have no special meaning (e.g., in a text), and we must read the data behind this character to complete the current tag reading. This treatment concerns the mode of work when myTagPerStep is true.
3) Create a test case of reading of XML file not related to OCAF document.
Test case was added.
}
else if (myTagPerStep && aHasRead)
{
+ // in myTagPerStep mode, we should parse the buffer to the end before
+ // getting more characters from the stream.
}
else
{
aState = STATE_TEXT;
aStartData = myPtr;
myPtr = myEndPtr;
+ aHasRead = Standard_False;
} // end of checking in STATE_WAITING
continue;
return XML_HEADER;
}
myPtr = myEndPtr - 1;
+ aHasRead = Standard_False;
continue;
// Checking the characters in STATE_DOCTYPE, seek for "]>" sequence
}
}
myPtr = myEndPtr - 1;
+ aHasRead = Standard_False;
continue;
state_doctype_markup:
return XML_DOCTYPE;
}
myPtr = myEndPtr - 1;
+ aHasRead = Standard_False;
continue;
// Checking the characters in STATE_COMMENT, seek for "-->" sequence
}
}
myPtr = myEndPtr - 2;
+ aHasRead = Standard_False;
continue;
// Checking the characters in STATE_TEXT, seek for "<"
return XML_TEXT;
}
myPtr = myEndPtr;
+ aHasRead = Standard_False;
continue;
// Checking the characters in STATE_CDATA, seek for "]]"
return XML_CDATA;
}
myPtr = myEndPtr - 1;
+ aHasRead = Standard_False;
continue;
// Checking the characters in STATE_ELEMENT, seek the end of TagName
myPtr = aPtr + 1;
aStartData = NULL;
aState = STATE_ATTRIBUTE_NAME;
- } else
+ }
+ else {
myPtr = myEndPtr;
+ aHasRead = Standard_False;
+ }
continue;
}
// Checking the characters in STATE_ELEMENT_END, seek for ">"
return XML_END_ELEMENT;
}
myPtr = myEndPtr;
+ aHasRead = Standard_False;
continue;
}
}
{
TCollection_ExtendedString aFormat;
- Storage_BaseDriver* aFileDriver;
+ Storage_BaseDriver* aFileDriver = 0L;
if (PCDM::FileDriverType (theIStream, aFileDriver) == PCDM_TOFD_XmlFile)
{
return ::TryXmlDriverType (theIStream);
}
-
+ if (!aFileDriver)
+ {
+ // type is not recognized, return empty string
+ return aFormat;
+ }
aFileDriver->ReadCompleteInfo (theIStream, theData);
--- /dev/null
+puts "REQUIRED All: DDocStd_Open : Error"
+
+puts "========"
+puts "OCC27454"
+puts "========"
+puts ""
+###################################################
+## Application hangs while opening a non-OCAF XML file
+###################################################
+
+cpulimit 10
+
+catch {Open [locate_data_file bug27454_test.xml] D -stream} msg
+
+cpulimit
+
+if ![regexp {DDocStd_Open : Error} $msg] {
+ puts "Error: reader did not report an error reading the file of unknown format"
+}
\ No newline at end of file
--- /dev/null
+puts "========"
+puts "OCC27454"
+puts "========"
+puts ""
+###################################################
+## Application hangs while opening a non-OCAF XML file
+###################################################
+
+if [info exists D] {unset D}
+Open [locate_data_file shape_tracking.ocaf.xml] D -stream
+
+if {[dtyp D] != "TDocStd_Document"} {
+ puts "Error: XML OCAF document read failure"
+}
+
+Close D