From 2be766f26756b1793759f3906a4a9c62dce6cda5 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Mon, 2 Apr 2018 17:15:42 +0000 Subject: [PATCH] Bug 61267: detect Word v2 files and report that they are not supported in Apache POI git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1828176 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/TestAllFiles.java | 2 ++ .../apache/poi/stress/HPSFFileHandler.java | 3 ++- .../poi/poifs/filesystem/FileMagic.java | 3 ++- .../apache/poi/poifs/storage/HeaderBlock.java | 3 +++ .../hwpf/usermodel/TestHWPFOldDocument.java | 19 +++++++++++++++--- test-data/document/word2.doc | Bin 0 -> 14662 bytes 6 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 test-data/document/word2.doc diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java index 77651274e..333a8ebcd 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/TestAllFiles.java @@ -302,6 +302,8 @@ public class TestAllFiles { "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", diff --git a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java index a5baa4adb..680cac839 100644 --- a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java @@ -54,7 +54,8 @@ public class HPSFFileHandler extends POIFSFileHandler { "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 EXCLUDES_HANDLE_FILE = unmodifiableHashSet( diff --git a/src/java/org/apache/poi/poifs/filesystem/FileMagic.java b/src/java/org/apache/poi/poifs/filesystem/FileMagic.java index 6bde1ced8..765cf6e32 100644 --- a/src/java/org/apache/poi/poifs/filesystem/FileMagic.java +++ b/src/java/org/apache/poi/poifs/filesystem/FileMagic.java @@ -77,10 +77,11 @@ public enum FileMagic { PDF("%PDF"), /** Some different HTML documents */ HTML("ohD;=n~$h_I5El(h*;92M3WU6Br%XuGorD_lG9fKp z$f?U>Ng?WmXiH4ovy$mTOV9U;#RbdE8@+04B9-V!v_!xL{%ABAsg}RR)brf~J%xO?XyTwYm-VHF zDN;tdCtt`Gx=o`(M=%(5OE>|EB3e~&SthrjI z*N~QpL`Dz!g@R* zug4!&vstTbHguNzN}7==Yw3KA?$u(7Wwh!}meJ!Depfi`_PBkj-Zf6?KGCgWsbsv` zt>VSfN(vq6)YVjdwRIy)lBte(WJIIdr>K#XI>+Y~ZV?RoLw*r(2Sci9r=aPbdPAwc z+NOG`Mrk8i-OP&xW~W|M6CIJZrkGgBw`ixmd(5=fSxJt`!{P$+MybDG^%lpth<2R;$`uq#W}0e_wZx){RuNA{ zTH+Cr)cUlDRwMg3b?prcm)kAqQ%qjLpxP%>B6B;XhHBBxlAdJ-Gi%lP0==(912JNC zt1z&`)gBaKpW0bXLrcpv8n&m}W4WB3FB@6WSYDx988ffSnKW%MUD>Twqqwrgg=})4 z-xCh_LN3*)CZc7kiF_jK(VeWwGGUqBW{CnX)C=V|@;lPrO$(}h&Tem?oVh!@NQL=o zo6Rhz%69sqC7N`zyIW1hW392aq=+=tC~9RC(V<*HkK4r%>XT<`-SW(aqG{xe{8(M7 z$*}ZnMl@};a;$+)E<>|&uAHZj$tk&5Bjd&x!#6CvF5zV@@Pxe{k6KAl>n<2F$!%o6 zB-sNq>9y8M?9KLCRhnuYh;#`nFWN~%Yq|(p|D#mXS=kXa`o&6IgX0OLVk=v zv#8LM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