vtkXMLDataParser: track `AppendedData` state explicitly
authorBen Boeckel <ben.boeckel@kitware.com>
Tue, 16 Apr 2024 02:22:22 +0000 (22:22 -0400)
committerAnton Gladky <gladk@debian.org>
Thu, 6 Jun 2024 19:34:35 +0000 (21:34 +0200)
Bug-Debian: https://bugs.debian.org/1064762
Origin: upstream,https://gitlab.kitware.com/vtk/vtk/-/commit/3efa07ad277efe5c1d11a2ef2b907c095f68bbef
Forwarded: not-needed

Newer `libexpat` doesn't like being given the appended data after the
artificially ended document anymore. Avoid pushing it through to its
parser.

Gbp-Pq: Name 09_newer_expat.patch

IO/XMLParser/vtkXMLDataParser.cxx
IO/XMLParser/vtkXMLDataParser.h

index 1f6006d37c2bde2c5f2dac1b135555007f11f3ec..7d38092fdd735db198331f4bf960cc9b1529131c 100644 (file)
@@ -36,6 +36,7 @@ vtkXMLDataParser::vtkXMLDataParser()
   this->RootElement = nullptr;
   this->AppendedDataPosition = 0;
   this->AppendedDataMatched = 0;
+  this->AppendedDataFound = false;
   this->DataStream = nullptr;
   this->InlineDataStream = vtkBase64InputStream::New();
   this->AppendedDataStream = vtkBase64InputStream::New();
@@ -88,6 +89,7 @@ void vtkXMLDataParser::PrintSelf(ostream& os, vtkIndent indent)
 {
   this->Superclass::PrintSelf(os, indent);
   os << indent << "AppendedDataPosition: " << this->AppendedDataPosition << "\n";
+  os << indent << "AppendedDataFound: " << this->AppendedDataFound << "\n";
   if (this->RootElement)
   {
     this->RootElement->PrintXML(os, indent);
@@ -214,7 +216,7 @@ int vtkXMLDataParser::ParsingComplete()
   // If we have reached the appended data section, we stop parsing.
   // This prevents the XML parser from having to walk over the entire
   // appended data section.
-  if (this->AppendedDataPosition)
+  if (this->AppendedDataPosition || this->AppendedDataFound)
   {
     return 1;
   }
@@ -433,6 +435,8 @@ int vtkXMLDataParser::ParseBuffer(const char* buffer, unsigned int count)
     {
       return 0;
     }
+
+    this->AppendedDataFound = true;
   }
 
   return 1;
index 1504a4d400b3a74f8392fc66388f741cb77be008..142bf28327d295dd48d5f9c4b69de4b02347ef9e 100644 (file)
@@ -204,6 +204,9 @@ protected:
   // How much of the string "<AppendedData" has been matched in input.
   int AppendedDataMatched;
 
+  // Whether AppendedData has been dealt with or not.
+  bool AppendedDataFound;
+
   // The byte order of the binary input.
   int ByteOrder;