You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/01/28 13:05:14 UTC
svn commit: r904052 - in /poi/trunk: src/documentation/content/xdocs/
src/scratchpad/src/org/apache/poi/hdgf/chunks/
src/scratchpad/testcases/org/apache/poi/hdgf/ test-data/diagram/
Author: nick
Date: Thu Jan 28 12:05:13 2010
New Revision: 904052
URL: http://svn.apache.org/viewvc?rev=904052&view=rev
Log:
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
Added:
poi/trunk/test-data/diagram/NegativeChunkLength2.vsd (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=904052&r1=904051&r2=904052&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Jan 28 12:05:13 2010
@@ -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>
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java?rev=904052&r1=904051&r2=904052&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java Thu Jan 28 12:05:13 2010
@@ -180,6 +180,14 @@
// 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++) {
@@ -190,7 +198,7 @@
if(endsAt == startsAt) {
endsAt = contents.length;
}
-
+
int strLen = (endsAt-startsAt) / 2;
command.value = StringUtil.getFromUnicodeLE(contents, startsAt, strLen);
break;
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java?rev=904052&r1=904051&r2=904052&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java Thu Jan 28 12:05:13 2010
@@ -33,7 +33,10 @@
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; }
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java?rev=904052&r1=904051&r2=904052&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java Thu Jan 28 12:05:13 2010
@@ -63,13 +63,18 @@
}
/**
- * 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);
}
}
Added: poi/trunk/test-data/diagram/NegativeChunkLength2.vsd
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/diagram/NegativeChunkLength2.vsd?rev=904052&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/diagram/NegativeChunkLength2.vsd
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org