]> source.dussan.org Git - poi.git/commitdiff
Bug 60374: Add test for ArrayIndexOutOfBounds on old Word Documents due to Non-Unicode
authorDominik Stadler <centic@apache.org>
Fri, 9 Jun 2017 12:47:03 +0000 (12:47 +0000)
committerDominik Stadler <centic@apache.org>
Fri, 9 Jun 2017 12:47:03 +0000 (12:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1798200 13f79535-47bb-0310-9956-ffa450edef68

src/integrationtest/org/apache/poi/TestAllFiles.java
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
test-data/document/cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC [new file with mode: 0644]

index 3dafca29157798b48c55de7e9f0fc819d8a81010..f3d79eb17234f87b0e979eef8015a883e7fb6056 100644 (file)
@@ -230,10 +230,10 @@ public class TestAllFiles {
         FILE_PASSWORD = Collections.unmodifiableMap(passmap);
     }
 
-    private static final Set<String> unmodifiableHashSet(String... a) {
+    private static Set<String> unmodifiableHashSet(String... a) {
         return Collections.unmodifiableSet(hashSet(a));
     }
-    private static final Set<String> hashSet(String... a) {
+    private static Set<String> hashSet(String... a) {
         return new HashSet<String>(Arrays.asList(a));
     }
 
@@ -249,6 +249,7 @@ public class TestAllFiles {
         "document/Bug60936.doc",
         "document/Bug60942.doc",
         "document/Bug60942b.doc",
+        "document/cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC",
         "hpsf/TestMickey.doc",
         "document/52117.doc",
         "hpsf/TestInvertedClassID.doc",
index fc1011470f50753f7955153e1870e05195d862aa..af7c8c16735c98e2c233473db30e1afc9c21597e 100644 (file)
 
 package org.apache.poi.hwpf.extractor;
 
+import org.apache.poi.POIDataSamples;
+import org.apache.poi.POITextExtractor;
+import org.apache.poi.extractor.OLE2ExtractorFactory;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.junit.Test;
+
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.poi.POIDataSamples;
-import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
 
 /**
  * Tests for bugs with the WordExtractor
@@ -52,4 +57,15 @@ public final class TestWordExtractorBugs {
         extractor.getText();
         extractor.close();
     }
+
+    @Test
+    public void testBug60374() throws Exception {
+        NPOIFSFileSystem fs = new NPOIFSFileSystem(SAMPLES.openResourceAsStream("cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC"));
+        final POITextExtractor extractor = OLE2ExtractorFactory.createExtractor(fs);
+
+        // Check it gives text without error
+        assertNotNull(extractor.getText());
+
+        extractor.close();
+    }
 }
diff --git a/test-data/document/cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC b/test-data/document/cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC
new file mode 100644 (file)
index 0000000..5a9f0d2
Binary files /dev/null and b/test-data/document/cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC differ