Author: tallison
Date: Tue Oct 18 12:55:34 2016
New Revision: 1765433

URL: http://svn.apache.org/viewvc?rev=1765433&view=rev
Log:
BUG 60158 -- AIOOBE in VBAMacroReader

Modified:
    poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
    poi/trunk/src/java/org/apache/poi/util/RLEDecompressingInputStream.java
    poi/trunk/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java

Modified: poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java?rev=1765433&r1=1765432&r2=1765433&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java 
(original)
+++ poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java Tue Oct 
18 12:55:34 2016
@@ -265,6 +265,9 @@ public class VBAMacroReader implements C
     private static final int MODULETYPE_PROCEDURAL = 0x0021;
     private static final int MODULETYPE_DOCUMENT_CLASS_OR_DESIGNER = 0x0022;
     private static final int PROJECTLCID = 0x0002;
+    private static final int MODULE_NAME = 0x0019;
+    private static final int MODULE_NAME_UNICODE = 0x0047;
+    private static final int MODULE_DOC_STRING = 0x001c;
 
     /**
      * Reads VBA Project modules from a VBA Project directory located at

Modified: 
poi/trunk/src/java/org/apache/poi/util/RLEDecompressingInputStream.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/RLEDecompressingInputStream.java?rev=1765433&r1=1765432&r2=1765433&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/RLEDecompressingInputStream.java 
(original)
+++ poi/trunk/src/java/org/apache/poi/util/RLEDecompressingInputStream.java Tue 
Oct 18 12:55:34 2016
@@ -91,7 +91,7 @@ public class RLEDecompressingInputStream
                 return -1;
             }
         }
-        return buf[pos++];
+        return buf[pos++]& 0xFF;
     }
 
     @Override

Modified: 
poi/trunk/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java?rev=1765433&r1=1765432&r2=1765433&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java 
Tue Oct 18 12:55:34 2016
@@ -280,16 +280,13 @@ public class TestVBAMacroReader {
             }
         }
     }
-    
-    // This test is written as expected-to-fail and should be rewritten
-    // as expected-to-pass when the bug is fixed.
+
     @Test
     public void bug60158() throws IOException {
-        try {
-            fromFile(POIDataSamples.getDocumentInstance(), "60158.docm");
-            testPassesNow(60158);
-        } catch (ArrayIndexOutOfBoundsException e) {
-            skipTest(e);
-        }
+        File f = POIDataSamples.getDocumentInstance().getFile("60158.docm");
+        VBAMacroReader r = new VBAMacroReader(f);
+        Map<String, String> macros = r.readMacros();
+        assertNotNull(macros.get("NewMacros"));
+        assertContains(macros.get("NewMacros"), "' dirty");
     }
 }



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

Reply via email to