diff options
author | Nick Burch <nick@apache.org> | 2017-07-09 16:26:33 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2017-07-09 16:26:33 +0000 |
commit | 933f9c1201d54f9270aedc22847aec1b04a69ea5 (patch) | |
tree | 49f4de9d760e593c82eb72dcc90703e3b67e393c /src/java/org/apache | |
parent | 236678598e1d13968868e090b54fc876c8d5dab6 (diff) | |
download | poi-933f9c1201d54f9270aedc22847aec1b04a69ea5.tar.gz poi-933f9c1201d54f9270aedc22847aec1b04a69ea5.zip |
#61266 Test for old unsupported MS Write WRI files, and give a more helpful exception if found, plus unit tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1801376 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/poi/poifs/storage/HeaderBlock.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/java/org/apache/poi/poifs/storage/HeaderBlock.java b/src/java/org/apache/poi/poifs/storage/HeaderBlock.java index aced76bbe2..fe64f61c83 100644 --- a/src/java/org/apache/poi/poifs/storage/HeaderBlock.java +++ b/src/java/org/apache/poi/poifs/storage/HeaderBlock.java @@ -67,6 +67,13 @@ public final class HeaderBlock implements HeaderBlockConstants { 0x00, 0x00, // unused 0x00, 0x01 }; + + private static final byte[] MAGIC_MSWRITEa = { + 0x31, (byte)0xbe, 0x00, 0x00 + }; + private static final byte[] MAGIC_MSWRITEb = { + 0x32, (byte)0xbe, 0x00, 0x00 + }; private static final byte _default_value = ( byte ) 0xFF; @@ -159,6 +166,12 @@ public final class HeaderBlock implements HeaderBlockConstants { + "Formats such as Office 2003 XML are not supported"); } + // Old MS Write raw stream + if (cmp(MAGIC_MSWRITEa, data) || cmp(MAGIC_MSWRITEb, data)) { + throw new NotOLE2FileException("The supplied data appears to be in the old MS Write format. " + + "Apache POI doesn't currently support this format"); + } + // BIFF2 raw stream if (cmp(MAGIC_BIFF2, data)) { throw new OldExcelFormatException("The supplied data appears to be in BIFF2 format. " |