Browse Source

fixed bug 51670: avoid LeftoverDataException when reading .xls files with invalid LabelRecord

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1169725 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_8_BETA5
Yegor Kozlov 12 years ago
parent
commit
936bf2f9b3

+ 1
- 0
src/documentation/content/xdocs/status.xml View File

@@ -34,6 +34,7 @@

<changes>
<release version="3.8-beta5" date="2011-??-??">
<action dev="poi-developers" type="add">51670 - avoid LeftoverDataException when reading .xls files with invalid LabelRecords</action>
<action dev="poi-developers" type="add">51196 - prevent NPE in XWPFPicture.getPictureData() </action>
<action dev="poi-developers" type="add">51771 - prevent NPE when getting object data from OLEShape in HSLF</action>
<action dev="poi-developers" type="add">51196 - more progress with Chart APi in XSSF</action>

+ 12
- 1
src/java/org/apache/poi/hssf/record/LabelRecord.java View File

@@ -18,6 +18,8 @@
package org.apache.poi.hssf.record;

import org.apache.poi.util.HexDump;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;

/**
* Label Record (0x0204) - read only support for strings stored directly in the cell.. Don't
@@ -29,6 +31,8 @@ import org.apache.poi.util.HexDump;
* @see org.apache.poi.hssf.record.LabelSSTRecord
*/
public final class LabelRecord extends Record implements CellValueRecordInterface {
private final static POILogger logger = POILogFactory.getLogger(LabelRecord.class);

public final static short sid = 0x0204;

private int field_1_row;
@@ -62,6 +66,13 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
} else {
field_6_value = "";
}

if (in.remaining() > 0) {
logger.log(POILogger.INFO,
"LabelRecord data remains: " + in.remaining() +
" : " + HexDump.toHex(in.readRemainder())
);
}
}

/*
@@ -97,7 +108,7 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
*/
public boolean isUnCompressedUnicode()
{
return (field_5_unicode_flag == 1);
return (field_5_unicode_flag & 0x01) != 0;
}

/**

+ 6
- 0
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java View File

@@ -2173,4 +2173,10 @@ if(1==2) {
assertTrue(text.contains("Bottom Right Cell"));
}
}

public void test51670() {
HSSFWorkbook wb = openSample("51670.xls");
writeOutAndReadBack(wb);
}

}

BIN
test-data/spreadsheet/51670.xls View File


Loading…
Cancel
Save