poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r639242 - in /poi/trunk/src: java/org/apache/poi/hssf/record/RecordInputStream.java testcases/org/apache/poi/hssf/data/44643.xls testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Date Thu, 20 Mar 2008 11:02:44 GMT
Author: nick
Date: Thu Mar 20 04:02:39 2008
New Revision: 639242

URL: http://svn.apache.org/viewvc?rev=639242&view=rev
Log:
Fix for readCompressedUnicode not moaning about length=0, from bug #44643

Added:
    poi/trunk/src/testcases/org/apache/poi/hssf/data/44643.xls   (with props)
Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java?rev=639242&r1=639241&r2=639242&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java Thu Mar 20 04:02:39
2008
@@ -266,6 +266,9 @@
   }
     
   public String readCompressedUnicode(int length) {
+	if(length == 0) {
+		return "";
+	}
     if ((length < 0) || ((remaining() < length) && !isContinueNext())) {
             throw new IllegalArgumentException("Illegal length " + length);
     }
@@ -273,7 +276,7 @@
     StringBuffer buf = new StringBuffer(length);
     for (int i=0;i<length;i++) {
       if ((remaining() == 0) && (isContinueNext())) {
-        nextRecord();
+          nextRecord();
           int compressByte = readByte();
           if(compressByte != 0) throw new IllegalArgumentException("compressByte in continue
records must be 0 while reading compressed unicode");
       }

Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/44643.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/44643.xls?rev=639242&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/44643.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

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=639242&r1=639241&r2=639242&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 Thu Mar 20 04:02:39
2008
@@ -1204,6 +1204,20 @@
         
         assertEquals(2, wb.getNumberOfSheets());
     }
+    
+    /**
+     * Used to give problems due to trying to read a zero
+     *  length string, but that's now properly handled
+     */
+    public void test44643() throws Exception {
+        FileInputStream in = new FileInputStream(new File(cwd, "44643.xls"));
+        
+        // Used to blow up with an IllegalArgumentException
+        HSSFWorkbook wb = new HSSFWorkbook(in);
+        in.close();
+        
+        assertEquals(1, wb.getNumberOfSheets());
+    }
 }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message