poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1169725 - in /poi/trunk: src/documentation/content/xdocs/status.xml src/java/org/apache/poi/hssf/record/LabelRecord.java src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/51670.xls
Date Mon, 12 Sep 2011 13:03:05 GMT
Author: yegor
Date: Mon Sep 12 13:03:04 2011
New Revision: 1169725

URL: http://svn.apache.org/viewvc?rev=1169725&view=rev
Log:
fixed bug 51670:  avoid LeftoverDataException when reading .xls files with invalid LabelRecord

Added:
    poi/trunk/test-data/spreadsheet/51670.xls   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/LabelRecord.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=1169725&r1=1169724&r2=1169725&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Sep 12 13:03:04 2011
@@ -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>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/LabelRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/LabelRecord.java?rev=1169725&r1=1169724&r2=1169725&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/LabelRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/LabelRecord.java Mon Sep 12 13:03:04 2011
@@ -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 R
         } 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 R
      */
     public boolean isUnCompressedUnicode()
     {
-        return (field_5_unicode_flag == 1);
+        return (field_5_unicode_flag & 0x01) != 0;
     }
 
     /**

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=1169725&r1=1169724&r2=1169725&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 Sep 12 13:03:04
2011
@@ -2173,4 +2173,10 @@ if(1==2) {
           assertTrue(text.contains("Bottom Right Cell"));
        }
     }
+
+    public void test51670() {
+        HSSFWorkbook wb = openSample("51670.xls");
+        writeOutAndReadBack(wb);
+    }
+
 }

Added: poi/trunk/test-data/spreadsheet/51670.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/51670.xls?rev=1169725&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/51670.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


Mime
View raw message