mirror of https://github.com/apache/poi.git
Apply patch from Jukka from bug #43670 to improve HDGF v11 Separator detection, and handle short strings better, hopefully solving the Negative length of ChunkHeader issue
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@904052 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e9a497a0de
commit
161a341e6c
|
@ -34,6 +34,7 @@
|
|||
|
||||
<changes>
|
||||
<release version="3.7-SNAPSHOT" date="2010-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="fix">43670 - Improve HDGF ChunkV11 separator detection, and short string detection, to solve the "Negative length of ChunkHeader" problem</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">48617 - Optionally allow the overriding of the Locale used by DataFormatter to control how the default number and date formats should look</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">New event based xssf text extractor (XSSFEventBasedExcelExtractor)</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">ExtractorFactory can now be told to prefer Event Based extractors (current Excel only) on a per-thread or overall basis</action>
|
||||
|
|
|
@ -180,6 +180,14 @@ public final class Chunk {
|
|||
// A Little Endian String
|
||||
// Starts 8 bytes into the data segment
|
||||
// Ends at end of data, or 00 00
|
||||
|
||||
// Ensure we have enough data
|
||||
if(contents.length < 8) {
|
||||
command.value = "";
|
||||
break;
|
||||
}
|
||||
|
||||
// Find the end point
|
||||
int startsAt = 8;
|
||||
int endsAt = startsAt;
|
||||
for(int j=startsAt; j<contents.length-1 && endsAt == startsAt; j++) {
|
||||
|
|
|
@ -33,7 +33,10 @@ public final class ChunkHeaderV11 extends ChunkHeaderV6 {
|
|||
if(hasTrailer()) { return true; }
|
||||
|
||||
if(unknown2 == 2 && unknown3 == 0x55) { return true; }
|
||||
if(unknown2 == 2 && unknown3 == 0x54 && type == 0xa9) { return true; }
|
||||
if(unknown2 == 2 && unknown3 == 0x54 && type == 0xaa) { return true; }
|
||||
if(unknown2 == 2 && unknown3 == 0x54 && type == 0xb4) { return true; }
|
||||
if(unknown2 == 2 && unknown3 == 0x54 && type == 0xb6) { return true; }
|
||||
if(unknown2 == 3 && unknown3 != 0x50) { return true; }
|
||||
if(type == 0x69) { return true; }
|
||||
|
||||
|
|
|
@ -63,13 +63,18 @@ public final class TestHDGFCore extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that we can open a problematic file, that initially
|
||||
* appears to have a negative chunk length
|
||||
* Tests that we can open a problematic file, that used to
|
||||
* break with a negative chunk length
|
||||
*/
|
||||
public void DISABLEDtestNegativeChunkLength() throws Exception {
|
||||
public void testNegativeChunkLength() throws Exception {
|
||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength.vsd"));
|
||||
|
||||
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
||||
assertNotNull(hdgf);
|
||||
|
||||
// And another file
|
||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength2.vsd"));
|
||||
hdgf = new HDGFDiagram(fs);
|
||||
assertNotNull(hdgf);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue