You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2009/12/21 17:24:09 UTC
svn commit: r892862 - in /poi/trunk: src/documentation/content/xdocs/
src/java/org/apache/poi/hssf/record/
src/testcases/org/apache/poi/hssf/record/
src/testcases/org/apache/poi/hssf/usermodel/ test-data/spreadsheet/
Author: yegor
Date: Mon Dec 21 16:24:08 2009
New Revision: 892862
URL: http://svn.apache.org/viewvc?rev=892862&view=rev
Log:
fixed InterfaceEndRecord to tolerate unexpected record contents, see bug 47251
Added:
poi/trunk/src/testcases/org/apache/poi/hssf/record/TestInterfaceEndRecord.java
poi/trunk/test-data/spreadsheet/47251.xls (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=892862&r1=892861&r2=892862&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Dec 21 16:24:08 2009
@@ -34,7 +34,8 @@
<changes>
<release version="3.7-SNAPSHOT" date="2010-??-??">
- <action dev="POI-DEVELOPERS" type="fix">48415 - improved javadoc on HSSPicture.resize() </action>
+ <action dev="POI-DEVELOPERS" type="fix">47215 - fixed InterfaceEndRecord to tolerate unexpected record contents </action>
+ <action dev="POI-DEVELOPERS" type="fix">48415 - improved javadoc on HSSPicture.resize() </action>
<action dev="POI-DEVELOPERS" type="add">added Ant target to install artifacts in local repository </action>
<action dev="POI-DEVELOPERS" type="fix">48026 - fixed PageSettingsBlock to allow multiple HeaderFooterRecord records </action>
<action dev="POI-DEVELOPERS" type="fix">48202 - fixed CellRangeUtil.mergeCellRanges to work for adjacent cell regions </action>
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java?rev=892862&r1=892861&r2=892862&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java Mon Dec 21 16:24:08 2009
@@ -18,6 +18,9 @@
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Title: Interface End Record (0x00E2)<P>
@@ -28,17 +31,23 @@
* @version 2.0-pre
*/
public final class InterfaceEndRecord extends StandardRecord {
+ private static POILogger logger = POILogFactory.getLogger(InterfaceEndRecord.class);
+
public final static short sid = 0x00E2;
+ private byte[] _unknownData;
+
public InterfaceEndRecord()
{
}
- /**
- * @param in unused (since this record has no data)
- */
public InterfaceEndRecord(RecordInputStream in)
{
+ if(in.available() > 0){
+ _unknownData = in.readRemainder();
+ logger.log(POILogger.WARN, "encountered unexpected " +
+ _unknownData.length + " bytes in InterfaceEndRecord");
+ }
}
public String toString()
@@ -46,15 +55,19 @@
StringBuffer buffer = new StringBuffer();
buffer.append("[INTERFACEEND]\n");
+ buffer.append(" unknownData=").append(HexDump.toHex(_unknownData)).append("\n");
buffer.append("[/INTERFACEEND]\n");
return buffer.toString();
}
public void serialize(LittleEndianOutput out) {
+ if(_unknownData != null) out.write(_unknownData);
}
protected int getDataSize() {
- return 0;
+ int size = 0;
+ if(_unknownData != null) size += _unknownData.length;
+ return size;
}
public short getSid()
Added: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestInterfaceEndRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestInterfaceEndRecord.java?rev=892862&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestInterfaceEndRecord.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestInterfaceEndRecord.java Mon Dec 21 16:24:08 2009
@@ -0,0 +1,56 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record;
+
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexRead;
+import org.apache.poi.util.HexDump;
+import java.util.List;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Tests the serialization and deserialization of the EndSubRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestInterfaceEndRecord extends TestCase {
+
+ public void testCreate() {
+ InterfaceEndRecord record = new InterfaceEndRecord();
+ assertEquals(0, record.getDataSize());
+ }
+
+ /**
+ * Silently swallow unexpected contents in InterfaceEndRecord.
+ * Although it violates the spec, Excel silently reads such files.
+ */
+ public void testUnexpectedBytes_bug47251(){
+ String hex = "" +
+ "09 08 10 00 00 06 05 00 EC 15 CD 07 C1 C0 00 00 06 03 00 00 " + //BOF
+ "E2 00 02 00 B0 04 " + //INTERFACEEND with extra two bytes
+ "0A 00 00 00"; // EOF
+ byte[] data = HexRead.readFromString(hex);
+ List<Record> records = RecordFactory.createRecords(new ByteArrayInputStream(data));
+ assertEquals(3, records.size());
+ InterfaceEndRecord r = (InterfaceEndRecord)records.get(1);
+ assertEquals("[E2, 00, 02, 00, B0, 04]", HexDump.toHex(r.serialize()));
+ }
+}
\ No newline at end of file
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=892862&r1=892861&r2=892862&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Mon Dec 21 16:24:08 2009
@@ -1533,4 +1533,8 @@
public void test48026() {
openSample("48026.xls");
}
+
+ public void test47251() {
+ openSample("47251.xls");
+ }
}
Added: poi/trunk/test-data/spreadsheet/47251.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/47251.xls?rev=892862&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/spreadsheet/47251.xls
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org