poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1568813 - in /poi/trunk/src: java/org/apache/poi/hpsf/CodePageString.java testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java
Date Sun, 16 Feb 2014 19:35:56 GMT
Author: nick
Date: Sun Feb 16 19:35:55 2014
New Revision: 1568813

URL: http://svn.apache.org/r1568813
Log:
Patch and test from Jon Iles from bug #56138 - HPSF code page strings can be zero length

Modified:
    poi/trunk/src/java/org/apache/poi/hpsf/CodePageString.java
    poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java

Modified: poi/trunk/src/java/org/apache/poi/hpsf/CodePageString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/CodePageString.java?rev=1568813&r1=1568812&r2=1568813&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/CodePageString.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/CodePageString.java Sun Feb 16 19:35:55 2014
@@ -42,7 +42,7 @@ class CodePageString
         offset += LittleEndian.INT_SIZE;
 
         _value = LittleEndian.getByteArray( data, offset, size );
-        if ( _value[size - 1] != 0 ) {
+        if ( size != 0 && _value[size - 1] != 0 ) {
             // TODO Some files, such as TestVisioWithCodepage.vsd, are currently
             //  triggering this for values that don't look like codepages
             // See Bug #52258 for details

Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java?rev=1568813&r1=1568812&r2=1568813&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java Sun Feb 16 19:35:55
2014
@@ -138,4 +138,27 @@ public final class TestHPSFBugs extends 
        assertEquals("", si.getAuthor());
        assertEquals("Cour de Justice", dsi.getCompany());
    }
+   
+   /**
+    * CodePage Strings can be zero length
+    */
+   public void test56138() throws Exception {
+       DocumentInputStream dis;
+       POIFSFileSystem fs = 
+               new POIFSFileSystem(_samples.openResourceAsStream("TestZeroLengthCodePage.mpp"));
+       
+       dis = fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME);
+       SummaryInformation si = (SummaryInformation)PropertySetFactory.create(dis);
+       
+       dis = fs.createDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
+       DocumentSummaryInformation dsi = (DocumentSummaryInformation)PropertySetFactory.create(dis);
+       
+       // Test
+       assertEquals("MSProject", si.getApplicationName());
+       assertEquals("project1", si.getTitle());
+       assertEquals("Jon Iles", si.getAuthor());
+       
+       assertEquals("", dsi.getCompany());
+       assertEquals(2, dsi.getSectionCount());
+   }
 }



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


Mime
View raw message