diff options
author | PJ Fanning <fanningpj@apache.org> | 2023-08-02 08:58:34 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2023-08-02 08:58:34 +0000 |
commit | c488cae3f3536253d0bd2c7580f08193dd70b2da (patch) | |
tree | 741b2ab9a17f5e80374a8756e8df55b6875f9d52 | |
parent | dd1b0b1128d1380f99d17c5097fb0f9732592a93 (diff) | |
download | poi-c488cae3f3536253d0bd2c7580f08193dd70b2da.tar.gz poi-c488cae3f3536253d0bd2c7580f08193dd70b2da.zip |
[bug-66827] treat VML drawing entry for a comment that has incorrect type of TEXT as invalid
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911407 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java | 8 | ||||
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java | 12 |
2 files changed, 18 insertions, 2 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java index 9f7fe0801c..5d1932c908 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java @@ -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 extends POIXMLDocumentPart { } 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; } diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 3c55db989d..700196e53c 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -3891,7 +3891,17 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { 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(); + } + } + } } } |