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-ffa450edef68pull/562/head
assertEquals(modified, file.lastModified(), "File should not be modified by extractor"); | assertEquals(modified, file.lastModified(), "File should not be modified by extractor"); | ||||
if (extractor instanceof POIOLE2TextExtractor) { | 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.getDocumentSummaryInformationText()); | ||||
assertNotNull(hpsfExtractor.getSummaryInformationText()); | assertNotNull(hpsfExtractor.getSummaryInformationText()); | ||||
String text = hpsfExtractor.getText(); | String text = hpsfExtractor.getText(); | ||||
//System.out.println(text); | //System.out.println(text); | ||||
assertNotNull(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 | // test again with including formulas and cell-comments as this caused some bugs | ||||
assertNotNull(streamExtractor); | assertNotNull(streamExtractor); | ||||
assertNotNull(streamExtractor.getText()); | assertNotNull(streamExtractor.getText()); | ||||
assertNotNull(streamExtractor.getMetadataTextExtractor()); | |||||
} | } | ||||
} | } | ||||
} | } |
ArrayList<POITextExtractor> textExtractors = new ArrayList<>(); | ArrayList<POITextExtractor> textExtractors = new ArrayList<>(); | ||||
for (Entry dir : dirs) { | for (Entry dir : dirs) { | ||||
textExtractors.add(createExtractor((DirectoryNode) dir)); | |||||
if (dir instanceof DirectoryNode) { | |||||
textExtractors.add(createExtractor((DirectoryNode) dir)); | |||||
} | |||||
} | } | ||||
for (InputStream stream : nonPOIFS) { | for (InputStream stream : nonPOIFS) { | ||||
try { | try { |
excludes.put("protected_66115.xls", RecordFormatException.class); | excludes.put("protected_66115.xls", RecordFormatException.class); | ||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", IllegalStateException.class); | excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", IllegalStateException.class); | ||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class); | excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class); | ||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5175219985448960.xls", IndexOutOfBoundsException.class); | |||||
return excludes; | return excludes; | ||||
} | } |
Map<String, Class<? extends Throwable>> excludes = super.getExcludes(); | Map<String, Class<? extends Throwable>> excludes = super.getExcludes(); | ||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", RecordFormatException.class); | excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", RecordFormatException.class); | ||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class); | excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class); | ||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5175219985448960.xls", RecordFormatException.class); | |||||
return excludes; | return excludes; | ||||
} | } | ||||