aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Allison <tallison@apache.org>2017-07-14 13:54:06 +0000
committerTim Allison <tallison@apache.org>2017-07-14 13:54:06 +0000
commit5a9d05487df6f47ecb878dfa1b8e5430843b60e1 (patch)
treec0799a39562601bba814a76e19f24a6c52e1f875
parent1a8b5234eca4a4ae151abb3f68aa68eeb9095513 (diff)
downloadpoi-5a9d05487df6f47ecb878dfa1b8e5430843b60e1.tar.gz
poi-5a9d05487df6f47ecb878dfa1b8e5430843b60e1.zip
bug 61286/bug 61287 -- allow WriteProtectRecord to have 2 bytes, and allow for HeaderFooter to be empty.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1801966 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/poi/hssf/record/HeaderFooterBase.java7
-rw-r--r--src/java/org/apache/poi/hssf/record/WriteProtectRecord.java3
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java13
-rw-r--r--test-data/spreadsheet/61287.xlsbin0 -> 11776 bytes
4 files changed, 21 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/hssf/record/HeaderFooterBase.java b/src/java/org/apache/poi/hssf/record/HeaderFooterBase.java
index 53d5f46926..d0e23c73b0 100644
--- a/src/java/org/apache/poi/hssf/record/HeaderFooterBase.java
+++ b/src/java/org/apache/poi/hssf/record/HeaderFooterBase.java
@@ -36,6 +36,13 @@ public abstract class HeaderFooterBase extends StandardRecord {
protected HeaderFooterBase(RecordInputStream in) {
if (in.remaining() > 0) {
int field_1_footer_len = in.readShort();
+ //61287 -- if the footer_len == 0, there may not be a multibyte flag
+ if (field_1_footer_len == 0) {
+ field_3_text = "";
+ if (in.remaining() == 0) {
+ return;
+ }
+ }
field_2_hasMultibyte = in.readByte() != 0x00;
if (field_2_hasMultibyte) {
diff --git a/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java b/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java
index 14afeedc37..e958adb5eb 100644
--- a/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java
@@ -37,6 +37,9 @@ public final class WriteProtectRecord extends StandardRecord {
*/
public WriteProtectRecord(RecordInputStream in)
{
+ if (in.remaining() == 2) {
+ in.readShort();
+ }
}
public String toString()
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
index d4abaf59a5..54b8f4a96d 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -43,8 +44,6 @@ import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
-import javax.imageio.ImageIO;
-
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples;
@@ -3096,4 +3095,14 @@ public final class TestBugs extends BaseTestBugzillaIssues {
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
wb.close();
}
+
+ @Test
+ public void test61287() throws IOException {
+ final Workbook wb = HSSFTestDataSamples.openSampleWorkbook("61287.xls");
+ ExcelExtractor ex = new ExcelExtractor((HSSFWorkbook)wb);
+ String text = ex.getText();
+ assertContains(text, "资产负债表");
+ wb.close();
+ }
+
}
diff --git a/test-data/spreadsheet/61287.xls b/test-data/spreadsheet/61287.xls
new file mode 100644
index 0000000000..4d35295e35
--- /dev/null
+++ b/test-data/spreadsheet/61287.xls
Binary files differ