"spreadsheet/poc-xmlbomb.xlsx", // contains xml-entity-expansion
"spreadsheet/poc-xmlbomb-empty.xlsx", // contains xml-entity-expansion
"spreadsheet/poc-shared-strings.xlsx", // contains shared-string-entity-expansion
+ "document/61612a.docx",
+ "document/word2.doc",
// old Excel files, which we only support simple text extraction of
"spreadsheet/testEXCEL_2.xls",
"spreadsheet/55982.xls",
"spreadsheet/testEXCEL_3.xls",
"spreadsheet/testEXCEL_4.xls",
- "hpsf/Test_Humor-Generation.ppt"
+ "hpsf/Test_Humor-Generation.ppt",
+ "document/word2.doc"
);
static final Set<String> EXCLUDES_HANDLE_FILE = unmodifiableHashSet(
PDF("%PDF"),
/** Some different HTML documents */
HTML("<!DOCTYP".getBytes(UTF_8), "<html".getBytes(UTF_8)),
+ WORD2(new byte[]{ (byte)0xdb, (byte)0xa5, 0x2d, 0x00}),
// keep UNKNOWN always as last enum!
/** UNKNOWN magic */
UNKNOWN(new byte[0]);
-
+
final byte[][] magic;
FileMagic(long magic) {
case MSWRITE:
throw new NotOLE2FileException("The supplied data appears to be in the old MS Write format. "
+ "Apache POI doesn't currently support this format");
+ case WORD2:
+ throw new NotOLE2FileException("The supplied data appears to be an old Word version 2 file. "
+ + "Apache POI doesn't currently support this format");
case BIFF2:
case BIFF3:
case BIFF4:
// Can't open as HWPFDocument
HWPFTestDataSamples.openSampleFile("Word6.doc");
}
-
+
@Test
public void testWord6hwpfOld() throws IOException {
// Open
doc.close();
}
-
-
+ /**
+ * Test a simple Word 2 document
+ */
+ @Test(expected=IllegalArgumentException.class)
+ public void testWord2hwpf() throws IOException {
+ // Can't open as HWPFDocument
+ HWPFTestDataSamples.openSampleFile("word2.doc");
+ }
+
+ @Test(expected=RuntimeException.class)
+ public void testWord2hwpfOld() throws IOException {
+ // Open
+ HWPFTestDataSamples.openOldSampleFile("word2.doc");
+ }
+
/**
* Test a simple Word 95 document
*/