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
2880d934f9
commit
3aef368b71
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.7-SNAPSHOT" date="2010-??-??">
|
<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">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">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>
|
<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
|
// A Little Endian String
|
||||||
// Starts 8 bytes into the data segment
|
// Starts 8 bytes into the data segment
|
||||||
// Ends at end of data, or 00 00
|
// 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 startsAt = 8;
|
||||||
int endsAt = startsAt;
|
int endsAt = startsAt;
|
||||||
for(int j=startsAt; j<contents.length-1 && endsAt == startsAt; j++) {
|
for(int j=startsAt; j<contents.length-1 && endsAt == startsAt; j++) {
|
||||||
@ -190,7 +198,7 @@ public final class Chunk {
|
|||||||
if(endsAt == startsAt) {
|
if(endsAt == startsAt) {
|
||||||
endsAt = contents.length;
|
endsAt = contents.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strLen = (endsAt-startsAt) / 2;
|
int strLen = (endsAt-startsAt) / 2;
|
||||||
command.value = StringUtil.getFromUnicodeLE(contents, startsAt, strLen);
|
command.value = StringUtil.getFromUnicodeLE(contents, startsAt, strLen);
|
||||||
break;
|
break;
|
||||||
|
@ -33,7 +33,10 @@ public final class ChunkHeaderV11 extends ChunkHeaderV6 {
|
|||||||
if(hasTrailer()) { return true; }
|
if(hasTrailer()) { return true; }
|
||||||
|
|
||||||
if(unknown2 == 2 && unknown3 == 0x55) { 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 == 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(unknown2 == 3 && unknown3 != 0x50) { return true; }
|
||||||
if(type == 0x69) { 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
|
* Tests that we can open a problematic file, that used to
|
||||||
* appears to have a negative chunk length
|
* break with a negative chunk length
|
||||||
*/
|
*/
|
||||||
public void DISABLEDtestNegativeChunkLength() throws Exception {
|
public void testNegativeChunkLength() throws Exception {
|
||||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength.vsd"));
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength.vsd"));
|
||||||
|
|
||||||
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
||||||
assertNotNull(hdgf);
|
assertNotNull(hdgf);
|
||||||
|
|
||||||
|
// And another file
|
||||||
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength2.vsd"));
|
||||||
|
hdgf = new HDGFDiagram(fs);
|
||||||
|
assertNotNull(hdgf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
test-data/diagram/NegativeChunkLength2.vsd
Normal file
BIN
test-data/diagram/NegativeChunkLength2.vsd
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user