1073 Commits

Author SHA1 Message Date
Dominik Stadler
9d9865c9b8 Avoid NPE when handling diagrams in pptx
Fixes https://issues.oss-fuzz.com/issues/484589690
2026-02-21 15:39:54 +01:00
Dominik Stadler
e9e9612a1f Avoid ClassCastException when reading headers of EMF files 2026-02-21 15:39:54 +01:00
Dominik Stadler
1594baf696 Avoid NPE when updating cell-anchors 2026-02-21 15:39:54 +01:00
Dominik Stadler
839ce4a0f4 Avoid NPE in HSSFShapeGroup.setShapeId() 2026-02-21 15:39:54 +01:00
Dominik Stadler
260b22fb09 Handle slightly broken file with empty BlipFill properly 2026-02-21 15:39:54 +01:00
Dominik Stadler
bc02ef0703 Avoid NPE with malformed wmf headers 2026-02-14 21:26:00 +01:00
Dominik Stadler
692caf0f36 Avoid NPE with malformed master-style 2026-02-14 21:26:00 +01:00
Dominik Stadler
e96c9e17c0 Avoid NPE with malformed EscherAggregate 2026-02-14 21:26:00 +01:00
Dominik Stadler
55c1608a2d Avoid NPE with malformed anchors in slideshow files 2026-02-14 21:26:00 +01:00
Dominik Stadler
5338b17a8f Avoid NPE with malformed Visio diagram
Fixes https://issues.oss-fuzz.com/issues/477312394
2026-02-14 21:26:00 +01:00
Dominik Stadler
c92c533d7a Prevent large allocations when writing PPDrawing items
Add an allocation check which can be disabled if necessary.

Fixes https://issues.oss-fuzz.com/issues/477289649 and https://issues.oss-fuzz.com/issues/479564936
2026-02-14 21:26:00 +01:00
Dominik Stadler
ab196a7441 Use log instead of assert when parsing emf-files
Assert effectively hides problem in provided input files.
2026-01-24 14:47:30 +01:00
Dominik Stadler
da3d64d9e3 Add an NPE check when retrieving fonts for bullet-items 2026-01-24 14:47:30 +01:00
Dominik Stadler
d1f3f9489f Add check for too large allocation in SharedFormulaGroup
A malformed spreadsheet could trigger a very large allocation.

Can be overruled by users via IOUtils.setByteArrayMaxOverride().

Fixes https://issues.oss-fuzz.com/issues/476431391
2026-01-18 18:28:36 +01:00
Dominik Stadler
d1f0a88ea1 Avoid NPE in XSLFDiagram
Throw IllegalStateException instead

Fixes https://issues.oss-fuzz.com/issues/476184825
2026-01-18 18:28:36 +01:00
Dominik Stadler
66109187d1 Only allocate the required size for EscherComplexProperty
Otherwise a malformed document can cause OOM by reserving
large chunks of memory, but only using little of it.

This fixes https://issues.oss-fuzz.com/issues/476184826
2026-01-18 18:28:36 +01:00
Jacobo Aragunde Pérez
372388b7ed
Support rendering transparent bitmaps in presentations. (#990)
* Support rendering transparent bitmaps in presentations.

Add PictureShape.getAlpha() method and implementations for HSLF and
XSLF. Then make use of it in DrawPictureShape to apply the right alpha
value to the picture being drawn.

Fixed a bug in BitmapImageRenderer that considered alpha value 0 as
"fully opaque", when it means "fully transparent" instead.

Finally, added a test for this feature in TestDrawPictureShape for XSLF.
A test for HSLF could not be created because it was not possible to
generate a test file with today's tools; MS Office removes the
bitmap transparency effect when saving as .ppt, and LibreOffice blends
it into the bitmap.

* Address reviewer comments.

* Add comment about default alpha value.

* Prevent NPE in XSLFPictureShape.getAlpha().

* Change wording in comments to avoid the word "percentage".

* Use static vars for extreme alpha values.
2026-01-17 13:47:09 +01:00
Dominik Stadler
d72e3a608c Add a file-handler for .emf files
These can be embedded in slideshows and POI supports
some handling of them.

Also Tika uses this code to extract some textual information
from such images.
2026-01-16 18:49:27 +01:00
Dominik Stadler
1910fff53e Add a file-handler for .wmf files
These can be embedded in slideshows and POI supports
some handling of them.

Also Tika uses this code to extract some textual information
from such images.
2026-01-16 18:49:27 +01:00
Dominik Stadler
9c2f487c98 Bug 69927: Avoid NPE when parsing wmf-file
headerBitCount can be null if the header contains an
invalid flag
2026-01-16 18:49:27 +01:00
Dominik Stadler
2acb5cf66a Avoid several NPEs
When retrieving picture data
When retrieving text in slides
When handling XSLFTableStyles
In EmbeddedExtractor if ShapeName is not set
In HSSF with invalid EscherSpRecord
In HSSF with invalid RecordStreams
When drawing arcs for shapes in slides
In HSSFPicture.getPictureIndex
Adjust "opens" for tests in poi-ooxml

Either handle it gracefully or throw
IllegalStateException instead for broken files
2026-01-16 18:49:27 +01:00
Dominik Stadler
1fc4f9e3b7 Avoid ClastCastException when handling a broken ppt file 2026-01-12 06:48:23 +01:00
Dominik Stadler
b401b92aea Avoid NPE when reading a broken pptx file 2026-01-12 06:48:23 +01:00
Dominik Stadler
a5f5f4294e Avoid NPE when reading a broken xlsb file
Throw a more useful exception instead
2026-01-12 06:48:23 +01:00
Dominik Stadler
f8a8189230 Use the proper add-method to perform the check for max number of children
If adding is done without check it can trigger OOM when fuzzing.

This should fix https://issues.oss-fuzz.com/issues/391709145
2026-01-10 13:14:34 +01:00
Dominik Stadler
95b2a1cf1d Avoid NPE with broken files when reading xls file 2026-01-10 13:14:34 +01:00
Dominik Stadler
017ff5f8f8 Implement lazy allocation of data for complex escher properties
This may reduce memory usage if the content is never used
or not populated for some reason.

This should fix https://issues.oss-fuzz.com/issues/42528528
2026-01-10 13:14:34 +01:00
Dominik Stadler
c94e795f35 Avoid NPE with broken files when writing endnotes for Word documents
https://issues.oss-fuzz.com/issues/391728757
2026-01-09 08:45:03 +01:00
Dominik Stadler
e9b33c0b08 Avoid NPE with broken files when writing endnotes for Word documents
Fixes https://issues.oss-fuzz.com/issues/392690733
2026-01-09 08:45:03 +01:00
Dominik Stadler
befc941dcf Avoid NPE with broken files when handling paint-style for fill 2026-01-09 08:45:03 +01:00
Dominik Stadler
ac989335d7 Avoid NPE with broken files when handling text-shapes 2026-01-09 08:45:03 +01:00
Dominik Stadler
0ec4434f59 Avoid NPE with broken file 2026-01-09 08:45:03 +01:00
Dominik Stadler
c28aec61d4 Avoid an NPE when reading broken SlideShow-files 2026-01-09 08:45:03 +01:00
Dominik Stadler
ddf71d0984 Avoid two NPEs which were currently "expected" in tests
When things go wrong, we always want to give an
explanation via an exception instead of an NPE.
2026-01-06 22:47:00 +01:00
emmanueldufour
528591ba11
Allow to load a word document with chartex chart (#982)
* Allow to load a word document with chartex chart

ChartEx (new charts introduced in Office 2016) will raise exceptions in underlying XML parsing, we catch them here in order to still be able to load the document

* spacing

some extra spaces were unbearable and could have prevented the pull request

* add test

* Update POIXMLDocumentPart.java

* Update POIXMLDocumentPart.java

* Update POIXMLDocumentPart.java

* reduce risk of swallowing zip bomb exceptions

* Update POIXMLDocumentPart.java

---------

Co-authored-by: PJ Fanning <pjfanning@users.noreply.github.com>
2025-12-19 20:10:25 +01:00
Dominik Stadler
338882ac88 Convert some files to unix newlines
Otherwise these can cause issues when checking out
sources on Windows
2025-12-17 22:11:29 +01:00
Jacobo Aragunde Pérez
4fb34ebeae
Fix rules for table style application in XSLFTables. (#969)
* Fix rules for table style application in XSLFTables.

Table styles contain rules for first and last rows/columns, even and
odd rows/columns... When one of these rules is empty, we are supposed
to fall back to the "whole table" rules. The fallback must also be
applied for the format that's not explicitly specified in the specific
rules.

when the corresponding specific rule is missing some info.

Fallback must also be applied when the corresponding specific rule is
missing some info. A couple of examples from the reproducer/test file
included:

The included reproducer/test file contained a few problems related to
table style application:
* The second style for horizontal/vertical banding (band2H, band2V) was
  never applied.
* In the table with horizontal banding enabled, the style band1H did
  not set a font color, POI returned a null font color instead of the
  color from wholeTable.
* In the table with horizontal banding enabled, the style band2H did
  not set a background color, POI returned null instead of the color
  specified in wholeTable.

This patches fixes the behaviors mentioned above, making POI behavior
match the one from MS Office and LibreOffice.

* Replace uses of java.util.list.getFirst().
2025-12-16 18:03:45 +01:00
Jacobo Aragunde Pérez
775da74dee
Fix NPE in XWPFParagraph.getCTSpacing(). (#950)
We recently changed the getters so they don't create the PPr object if
it doesn't exist, but we missed adding one null check for the new
situation.

Add a test to exercise all the getters in a case where there isn't a PPr
object.
2025-11-24 20:44:02 +01:00
Dominik Stadler
25a2dd9227 Adjust parsing XSSFBuiltinTableStyle
In case of invalid enum-value keep the fallback-handling
as before as otherwise some existing documents fail to parse
2025-11-03 07:26:03 +01:00
Dominik Stadler
207d67c12b Prevent a NullPointerException
The regression-corpus contains some documents which trigger this,
but succeed with the added null-check
2025-11-03 07:26:03 +01:00
Dominik Stadler
ea74954fcf Trigger reading metadata-text as part of integration testing
One test-case fails differently now
2025-10-06 07:40:53 +02:00
Dominik Stadler
42193c57e4 Try to verify handling of deeply nested xlsx 2025-10-06 07:40:53 +02:00
PJ Fanning
d0e6830e44
issue when formatting number when divisor is needed (#895)
* reproduce issue 69812

* workaround for issue
2025-09-09 22:27:48 +01:00
PJ Fanning
00c2a85c30 Update HeaderFooterComplexFormats.xlsx 2025-08-28 15:14:57 +01:00
PJ Fanning
9f9ff14e56 add test 2025-08-28 13:00:54 +01:00
PJ Fanning
9d37011683
workaround stray whitespace in sst index (#874)
* tolerate whitespace in ints

* try to workaround stray whitespace in sst index

* Update TestAllFiles.java
2025-08-05 12:00:54 +01:00
PJ Fanning
b50ce609ca
check xwpf node depth (#869)
* check xwpf node depth

* Update TestAllFiles.java

* Update TestAllFiles.java
2025-08-01 20:28:05 +01:00
PJ Fanning
8d71c1f2ff add poifs test 2025-07-30 18:54:05 +01:00
Jacobo Aragunde Pérez
cceccc4bae
Support all possible alignment values for docx tables. (#848)
Besides the start/center/end values specified in the OOXML standard,
Word also uses "left" and "right" as values. We need to support this
to prevent POI code from crashing with such documents.

Fixes: https://bz.apache.org/bugzilla/show_bug.cgi?id=69744
2025-07-17 12:11:46 +01:00
Jacobo Aragunde Pérez
73b2874824
Add getters and setters for XWPFTable indentation. (#843)
* Add getters and setters for XWPFTable indentation.

The element tblPr->tblInd represents "table indent from leading margin".
It specifies the indentation which shall be added before the leading
edge of the current table in the document (the left edge in a
left-to-right table, and the right edge in a right-to-left table). This
indentation should shift the table into the text margin by the specified
amount.

This value is specified in the units applied via its type attribute. Any
width value of type pct or auto for this element shall be ignored.

If this element is omitted, then the table shall inherit the table
indentation from the associated table style. If table indentation is
never specified in the style hierarchy, no indentation shall be added to
the parent table. If the resulting justification on any table row is not
left, then this property shall be ignored.

To implement this property, we included a getter and a setter for the
property value, and another couple of getter/setter for the existence
(and validity) or absence of the property itself, for clients to know
they must fall back to the table style.

* Address reviewer comments.
2025-07-15 10:05:17 +01:00