Author: fanningpj
Date: Wed Aug  2 08:58:34 2023
New Revision: 1911407

URL: http://svn.apache.org/viewvc?rev=1911407&view=rev
Log:
[bug-66827] treat VML drawing entry for a comment that has incorrect type of 
TEXT as invalid

Modified:
    
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java
    
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java

Modified: 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java?rev=1911407&r1=1911406&r2=1911407&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java
 (original)
+++ 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java
 Wed Aug  2 08:58:34 2023
@@ -55,6 +55,7 @@ import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException;
 import org.openxmlformats.schemas.officeDocument.x2006.sharedTypes.STTrueFalse;
 
 /**
@@ -301,7 +302,12 @@ public final class XSSFVMLDrawing extend
         }
 
         CTClientData cldata = sh.getClientDataArray(0);
-        if(cldata.getObjectType() != STObjectType.NOTE) {
+        try {
+            if (cldata.getObjectType() != STObjectType.NOTE) {
+                return false;
+            }
+        } catch (XmlValueOutOfRangeException e) {
+            // see https://bz.apache.org/bugzilla/show_bug.cgi?id=66827
             return false;
         }
 

Modified: 
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1911407&r1=1911406&r2=1911407&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
 (original)
+++ 
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
 Wed Aug  2 08:58:34 2023
@@ -3891,7 +3891,17 @@ public final class TestXSSFBugs extends
             for (int i = 0; i < expectedCount; i++) {
                 assertNotNull(sst.getItemAt(i));
             }
-
+            XSSFSheet ws = wb.getSheetAt(0);
+            int nRowCount = ws.getLastRowNum(); // does not include header row 
in the count
+            for (int r = 1; r <= nRowCount; r++) {
+                XSSFRow row = ws.getRow(r);
+                if (row != null) {
+                    XSSFCell cellSymbol = row.getCell(0);
+                    if (cellSymbol != null) {
+                        XSSFComment comment = cellSymbol.getCellComment();
+                    }
+                }
+            }
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to