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
This commit is contained in:
Tim Allison 2017-07-14 13:54:06 +00:00
parent 1a8b5234ec
commit 5a9d05487d
4 changed files with 21 additions and 2 deletions

View File

@ -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) {

View File

@ -37,6 +37,9 @@ public final class WriteProtectRecord extends StandardRecord {
*/
public WriteProtectRecord(RecordInputStream in)
{
if (in.remaining() == 2) {
in.readShort();
}
}
public String toString()

View File

@ -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();
}
}

Binary file not shown.