You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2017/03/10 20:13:52 UTC

svn commit: r1786431 - in /poi/trunk/src: integrationtest/org/apache/poi/TestAllFiles.java java/org/apache/poi/hssf/record/CFRule12Record.java

Author: centic
Date: Fri Mar 10 20:13:52 2017
New Revision: 1786431

URL: http://svn.apache.org/viewvc?rev=1786431&view=rev
Log:
HSSF: Try to handle cases where the length does not match the actual data while cloning, we see this in some documents

Modified:
    poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java
    poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java

Modified: poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java?rev=1786431&r1=1786430&r2=1786431&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/TestAllFiles.java Fri Mar 10 20:13:52 2017
@@ -177,10 +177,10 @@ public class TestAllFiles {
         HANDLERS.put("spreadsheet/test_properties1", new NullFileHandler());
     }
 
-    private static final Set<String> unmodifiableHashSet(String... a) {
+    private static Set<String> unmodifiableHashSet(String... a) {
         return Collections.unmodifiableSet(hashSet(a));
     }
-    private static final Set<String> hashSet(String... a) {
+    private static Set<String> hashSet(String... a) {
         return new HashSet<String>(Arrays.asList(a));
     }
 
@@ -279,12 +279,10 @@ public class TestAllFiles {
         // sheet cloning errors
         "spreadsheet/47813.xlsx",
         "spreadsheet/56450.xls",
-        "spreadsheet/57231_MixedGasReport.xls",
         "spreadsheet/OddStyleRecord.xls",
         "spreadsheet/WithChartSheet.xlsx",
         "spreadsheet/chart_sheet.xlsx",
-        "spreadsheet/SimpleScatterChart.xlsx",
-        "spreadsheet/ConditionalFormattingSamples.xls"
+        "spreadsheet/SimpleScatterChart.xlsx"
     );
 
     private static final Set<String> IGNORED = unmodifiableHashSet(

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java?rev=1786431&r1=1786430&r2=1786431&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java Fri Mar 10 20:13:52 2017
@@ -461,10 +461,12 @@ public final class CFRule12Record extend
         rec.futureHeader.setAssociatedRange(futureHeader.getAssociatedRange().copy());
         
         super.copyTo(rec);
-        
-        rec.ext_formatting_length = ext_formatting_length;
+
+        // use min() to gracefully handle cases where the length-property and the array-lenght do not match
+        // we saw some such files in circulation
+        rec.ext_formatting_length = Math.min(ext_formatting_length, ext_formatting_data.length);
         rec.ext_formatting_data = new byte[ext_formatting_length];
-        System.arraycopy(ext_formatting_data, 0, rec.ext_formatting_data, 0, ext_formatting_length);
+        System.arraycopy(ext_formatting_data, 0, rec.ext_formatting_data, 0, rec.ext_formatting_length);
         
         rec.formula_scale = formula_scale.copy();
         



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