Prechádzať zdrojové kódy

Merge pull request #13108 from jakesmith/hpcc-23046-despray-xml-bug

HPCC-23046 Fix loss of xml part content if smaller than headers

Reviewed-By: Attila Vamos <attila.vamos@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 rokov pred
rodič
commit
fd3cda6431
1 zmenil súbory, kde vykonal 8 pridanie a 10 odobranie
  1. 8 10
      dali/ft/filecopy.cpp

+ 8 - 10
dali/ft/filecopy.cpp

@@ -1087,17 +1087,15 @@ void FileSprayer::calculateMany2OnePartition()
     const char *partSeparator = srcFormat.getPartSeparatorString();
     offset_t partSeparatorLength = ( partSeparator == nullptr ? 0 : strlen(partSeparator));
     offset_t lastContentLength = 0;
-    offset_t contentLength = 0;
     ForEachItemIn(idx, sources)
     {
         FilePartInfo & cur = sources.item(idx);
         RemoteFilename curFilename;
         curFilename.set(cur.filename);
         setCanAccessDirectly(curFilename);
-        if (partSeparator)
+        if (cur.size)
         {
-            contentLength = (cur.size > cur.xmlHeaderLength + cur.xmlFooterLength  + partSeparatorLength ? cur.size - cur.xmlHeaderLength - cur.xmlFooterLength - partSeparatorLength : 0);
-            if (contentLength)
+            if (partSeparator)
             {
                 if (lastContentLength)
                 {
@@ -1105,14 +1103,10 @@ void FileSprayer::calculateMany2OnePartition()
                     part.whichOutput = 0;
                     partition.append(part);
                 }
-                lastContentLength = contentLength;
+                lastContentLength = cur.size;
             }
-        }
-        else
-            contentLength = (cur.size > cur.headerSize ? cur.size - cur.headerSize : 0);
-
-        if (contentLength)
             partition.append(*new PartitionPoint(idx, 0, cur.headerSize, cur.size, cur.size));
+        }
     }
 
     if (srcFormat.isCsv())
@@ -1616,7 +1610,11 @@ void FileSprayer::analyseFileHeaders(bool setcurheadersize)
                 }
                 cur.headerSize += (unsigned)cur.xmlHeaderLength;
                 if (cur.size >= cur.xmlHeaderLength + cur.xmlFooterLength)
+                {
                     cur.size -= (cur.xmlHeaderLength + cur.xmlFooterLength);
+                    if (cur.size <= srcFormat.rowTag.length()) // implies there's a header and footer but no rows (whitespace only)
+                        cur.size = 0;
+                }
                 else
                     throwError3(DFTERR_InvalidXmlPartSize, cur.size, cur.xmlHeaderLength, cur.xmlFooterLength);
             }