poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From max...@apache.org
Subject svn commit: r1001712 - in /poi/trunk: 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
Date Mon, 27 Sep 2010 12:50:36 GMT
Author: maxcom
Date: Mon Sep 27 12:50:36 2010
New Revision: 1001712

URL: http://svn.apache.org/viewvc?rev=1001712&view=rev
Log:
hwpt: add more 2 bytes to OldSectionTable to solve ArrayIndexOutOfBoundsException

Added:
    poi/trunk/test-data/document/word95err.doc   (with props)
Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java?rev=1001712&r1=1001711&r2=1001712&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java Mon Sep 27
12:50:36 2010
@@ -60,8 +60,8 @@ public final class OldSectionTable exten
         //  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));
       }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java?rev=1001712&r1=1001711&r2=1001712&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
Mon Sep 27 12:50:36 2010
@@ -273,7 +273,17 @@ public final class TestWordExtractor ext
         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 {

Added: poi/trunk/test-data/document/word95err.doc
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/word95err.doc?rev=1001712&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/document/word95err.doc
------------------------------------------------------------------------------
    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


Mime
View raw message