aboutsummaryrefslogtreecommitdiffstats
path: root/poi-integration/src
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-12-06 19:49:52 +0000
committerDominik Stadler <centic@apache.org>2023-12-06 19:49:52 +0000
commit15dd62d65957dc87b0aa2efab2f4561c17707607 (patch)
tree1edb628c09eb56f4ed4f2477423a8dfda7e9cc4f /poi-integration/src
parentc7329fbd38d1c22749448150ca180537ecbd8262 (diff)
downloadpoi-15dd62d65957dc87b0aa2efab2f4561c17707607.tar.gz
poi-15dd62d65957dc87b0aa2efab2f4561c17707607.zip
Bug 66425: Avoid exceptions found via poi-fuzz
Avoid a ClassCastException and trigger some more code in integration-testing. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63358 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1914404 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-integration/src')
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java
index c413fb0733..c1c96aaa12 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java
@@ -109,13 +109,38 @@ public abstract class AbstractFileHandler implements FileHandler {
assertEquals(modified, file.lastModified(), "File should not be modified by extractor");
if (extractor instanceof POIOLE2TextExtractor) {
- try (HPSFPropertiesExtractor hpsfExtractor = new HPSFPropertiesExtractor((POIOLE2TextExtractor) extractor)) {
+ POIOLE2TextExtractor ole2Extractor = (POIOLE2TextExtractor) extractor;
+ ole2Extractor.getRoot();
+ if (!(ole2Extractor instanceof EventBasedExcelExtractor)) {
+ ole2Extractor.getSummaryInformation();
+ ole2Extractor.getDocSummaryInformation();
+ }
+
+ try (HPSFPropertiesExtractor hpsfExtractor = new HPSFPropertiesExtractor(ole2Extractor)) {
assertNotNull(hpsfExtractor.getDocumentSummaryInformationText());
assertNotNull(hpsfExtractor.getSummaryInformationText());
String text = hpsfExtractor.getText();
//System.out.println(text);
assertNotNull(text);
}
+
+ if (ole2Extractor.getRoot() != null && !Boolean.getBoolean("scratchpad.ignore")) {
+ POITextExtractor[] embedded = ExtractorFactory.getEmbeddedDocsTextExtractors(ole2Extractor);
+ try {
+ for (POITextExtractor poiTextExtractor : embedded) {
+ poiTextExtractor.getText();
+ poiTextExtractor.getDocument();
+ poiTextExtractor.getFilesystem();
+ POITextExtractor metaData = poiTextExtractor.getMetadataTextExtractor();
+ metaData.getFilesystem();
+ metaData.getText();
+ }
+ } finally {
+ for (POITextExtractor embeddedExtractor : embedded) {
+ embeddedExtractor.close();
+ }
+ }
+ }
}
// test again with including formulas and cell-comments as this caused some bugs
@@ -166,6 +191,8 @@ public abstract class AbstractFileHandler implements FileHandler {
assertNotNull(streamExtractor);
assertNotNull(streamExtractor.getText());
+
+ assertNotNull(streamExtractor.getMetadataTextExtractor());
}
}
}