This is an automated email from the ASF dual-hosted git repository. centic9 pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/poi.git
commit 6df168bab549d9402bb6960d1f2d7922bfd45858 Author: Dominik Stadler <[email protected]> AuthorDate: Sun Oct 25 09:33:59 2026 +0100 Fuzzing: Adjust XSSFBFuzzer Add fuzzing XSSFWorkbook() Adjust expected exceptions --- .../java/org/apache/poi/fuzz/POIXSSFBFuzzer.java | 51 ++++++++++++++-------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIXSSFBFuzzer.java b/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIXSSFBFuzzer.java index 89d8fccc1d..dcb05b98b2 100644 --- a/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIXSSFBFuzzer.java +++ b/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIXSSFBFuzzer.java @@ -17,13 +17,16 @@ package org.apache.poi.fuzz; -import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.poi.ooxml.POIXMLException; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; +import org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.util.RecordFormatException; import org.apache.poi.xssf.binary.XSSFBParseException; import org.apache.poi.xssf.extractor.XSSFBEventBasedExcelExtractor; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.xmlbeans.XmlException; import java.io.ByteArrayInputStream; @@ -40,24 +43,34 @@ public class POIXSSFBFuzzer { } try (OPCPackage pkg = OPCPackage.open(new ByteArrayInputStream(input), true)) { - XSSFBEventBasedExcelExtractor ex = new XSSFBEventBasedExcelExtractor(pkg); - ex.getText(); - - /* Not supported: - ex.setFormulasNotResults(true); - ex.getText();*/ - - ex.setHandleHyperlinksInCells(true); - ex.getText(); - } catch (IOException | XmlException | OpenXML4JException | POIXMLException | - RecordFormatException | IndexOutOfBoundsException | IllegalArgumentException | - IllegalStateException | ArithmeticException | XSSFBParseException ex) { - // expected - } catch (NullPointerException e) { - // can be removed when commons-compress is > 1.28.0 and changes from COMPRESS-598 are applied - if (!ExceptionUtils.getStackTrace(e).contains("org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read")) { - throw e; - } + // use separate try-catch to try both things even if the first one fails + try { + new XSSFWorkbook(pkg).close(); + } catch (IOException | POIXMLException | + RecordFormatException | IndexOutOfBoundsException | IllegalArgumentException | + IllegalStateException | ArithmeticException | XSSFBParseException | + PartAlreadyExistsException e) { + // expected + } + + try { + XSSFBEventBasedExcelExtractor ex = new XSSFBEventBasedExcelExtractor(pkg); + ex.getText(); + + /* Not supported: + ex.setFormulasNotResults(true); + ex.getText();*/ + + ex.setHandleHyperlinksInCells(true); + ex.getText(); + } catch (IOException | XmlException | OpenXML4JException | POIXMLException | + RecordFormatException | IndexOutOfBoundsException | IllegalArgumentException | + IllegalStateException | ArithmeticException | XSSFBParseException e) { + // expected + } + } catch (IOException | InvalidFormatException | NotOfficeXmlFileException | + RecordFormatException ex) { + // expected } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
