]> source.dussan.org Git - poi.git/commitdiff
hwpt: add more 2 bytes to OldSectionTable to solve ArrayIndexOutOfBoundsException
authorMaxim Valyanskiy <maxcom@apache.org>
Mon, 27 Sep 2010 12:50:36 +0000 (12:50 +0000)
committerMaxim Valyanskiy <maxcom@apache.org>
Mon, 27 Sep 2010 12:50:36 +0000 (12:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1001712 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
test-data/document/word95err.doc [new file with mode: 0644]

index 87218b35e5473cb3a89c238ffe3a565b7ac442de..18819c32c9d58d8b4ab10e2fe5256aa7d9f8da64 100644 (file)
@@ -60,8 +60,8 @@ public final class OldSectionTable extends SectionTable
         //  section properties, and we're trying to decode them as if they
         //  were the new ones, we sometimes "need" more data than we have.
         // As a workaround, have a few extra 0 bytes on the end!
-        byte[] buf = new byte[sepxSize+2];
-        fileOffset += LittleEndian.SHORT_SIZE;
+        byte[] buf = new byte[sepxSize+4];
+        fileOffset += 4;
         System.arraycopy(documentStream, fileOffset, buf, 0, buf.length);
         _sections.add(new SEPX(sed, startAt, endAt, charConv, buf));
       }
index 1ef21db3a5a445270eb93b98b7d170da965ed6d8..690345322bf76ba5804188725f497287e4b6a0e5 100644 (file)
@@ -273,7 +273,17 @@ public final class TestWordExtractor extends TestCase {
         assertEquals("\r\n", tp[5]);
         assertEquals("Last (4th) paragraph.\r\n", tp[6]);
        }
-       
+
+    public void testWord95err() throws Exception {
+        // Can work with the special one
+        Word6Extractor w6e = new Word6Extractor(
+                POIDataSamples.getDocumentInstance().openResourceAsStream("word95err.doc")
+        );
+        String text = w6e.getText();
+
+        assertTrue(text.contains("subject"));
+    }
+
        public void testWord6() throws Exception {
         // Too old for the default
         try {
diff --git a/test-data/document/word95err.doc b/test-data/document/word95err.doc
new file mode 100644 (file)
index 0000000..7db961b
Binary files /dev/null and b/test-data/document/word95err.doc differ