Add parameter to the decode functions - #9399
Conversation
6a9161a to
3e6063a
Compare
3e6063a to
e9636c5
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9399 +/- ##
==========================================
+ Coverage 65.48% 65.61% +0.13%
==========================================
Files 116 117 +1
Lines 21534 21596 +62
Branches 10712 10740 +28
==========================================
+ Hits 14102 14171 +69
+ Misses 5141 5133 -8
- Partials 2291 2292 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR plumbs a new DecodeParams parameter through the various static decode() entry points so max_recursion_depth can be configured consistently across formats, removing the previously hard-coded recursion limit in XMP XML validation.
Changes:
- Introduced
DecodeParamsand added it as a parameter to multipledecode()APIs (Exif/TIFF/XMP/PNG chunks, etc.). - Stored
max_recursion_depthonImage(and removed per-derived copies) so image readers can propagate it to decode paths. - Updated unit tests and sample programs to supply
DecodeParamsexplicitly.
Show a summary per file
| File | Description |
|---|---|
| unitTests/unittest_utils.hpp | Adds a shared recursion depth constant and declares default DecodeParams helper. |
| unitTests/unittest_utils.cpp | Uses the shared constant and implements defaultDecodeParams(). |
| unitTests/test_xmp_race_encode_decode.cpp | Passes DecodeParams to XmpParser::decode() in concurrency tests. |
| unitTests/test_xmp_ns_leak.cpp | Passes DecodeParams to XmpParser::decode() in namespace regression tests. |
| unitTests/test_xmp_concurrent_registry.cpp | Passes DecodeParams to XmpParser::decode() in registry concurrency test. |
| src/xmpsidecar.cpp | Propagates max_recursion_depth_ into XMP decode via DecodeParams. |
| src/xmp.cpp | Removes hard-coded recursion limit; enforces recursion depth via DecodeParams in XML validation; updates XMP decode signature. |
| src/webpimage.cpp | Passes DecodeParams into Exif/XMP decoding from WebP chunks. |
| src/tiffvisitor_int.hpp | Extends TiffDecoder ctor to accept DecodeParams and stores max recursion depth. |
| src/tiffvisitor_int.cpp | Threads DecodeParams into TiffDecoder and XMP decode within TIFF. |
| src/tiffimage_int.hpp | Extends TiffParserWorker::decode() to accept DecodeParams. |
| src/tiffimage_int.cpp | Passes DecodeParams into TiffDecoder construction. |
| src/tiffimage.cpp | Threads DecodeParams through TiffParser::decode() and image readers. |
| src/tifffwd_int.hpp | Forward declares DecodeParams for internal TIFF code. |
| src/rw2image.cpp | Threads DecodeParams through RW2 decode into TIFF worker. |
| src/rafimage.cpp | Passes DecodeParams to embedded TIFF parsing. |
| src/quicktimevideo.cpp | Removes per-class recursion depth storage (now relies on base Image). |
| src/psdimage.cpp | Passes DecodeParams into PSD Exif and XMP decode paths. |
| src/pngimage.cpp | Creates DecodeParams and passes it into PNG text/exif chunk decoders. |
| src/pngchunk_int.hpp | Updates PNG chunk decode/parse APIs to accept DecodeParams. |
| src/pngchunk_int.cpp | Threads DecodeParams into TIFF/XMP decode from PNG chunk content. |
| src/orfimage.cpp | Threads DecodeParams through ORF decode into TIFF worker. |
| src/mrwimage.cpp | Passes DecodeParams to TIFF parser for MRW. |
| src/jpgimage.cpp | Passes DecodeParams into JPEG Exif and XMP decode paths. |
| src/jp2image.cpp | Passes DecodeParams into JP2 embedded Exif and XMP decode paths. |
| src/image.cpp | Stores max_recursion_depth_ on Image and uses it for setXmpPacket() decode. |
| src/exif.cpp | Implements DecodeParams ctor and updates ExifParser::decode() signature to accept it. |
| src/epsimage.cpp | Passes DecodeParams into EPS XMP decode path. |
| src/cr2image.cpp | Threads DecodeParams into CR2 decode and TIFF worker usage. |
| src/bmffimage.cpp | Removes per-class box depth member; uses max_recursion_depth_ and passes DecodeParams into TIFF/XMP parsing. |
| src/asfvideo.cpp | Removes per-class recursion depth storage (now relies on base Image). |
| samples/xmpparser-test.cpp | Updates sample to construct DecodeParams and pass to XMP decode. |
| samples/xmpparse.cpp | Updates sample to construct DecodeParams and pass to XMP decode. |
| samples/tiff-test.cpp | Updates sample to pass DecodeParams into Exif decode. |
| include/exiv2/xmp_exiv2.hpp | Updates XmpParser::decode() API to accept DecodeParams (forward declared). |
| include/exiv2/tiffimage.hpp | Updates TiffParser::decode() API to accept DecodeParams. |
| include/exiv2/rw2image.hpp | Updates Rw2Parser::decode() API to accept DecodeParams. |
| include/exiv2/quicktimevideo.hpp | Removes derived-class recursion depth member (base Image now stores it). |
| include/exiv2/orfimage.hpp | Updates OrfParser::decode() API to accept DecodeParams. |
| include/exiv2/image.hpp | Adds max_recursion_depth_ member to Image. |
| include/exiv2/exif.hpp | Introduces DecodeParams and updates ExifParser::decode() API signature. |
| include/exiv2/cr2image.hpp | Updates Cr2Parser::decode() API to accept DecodeParams. |
| include/exiv2/bmffimage.hpp | Removes derived-class max box depth member (base Image now used). |
| include/exiv2/asfvideo.hpp | Removes derived-class recursion depth member (base Image now stores it). |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Suppressed comments (3)
unitTests/unittest_utils.hpp:1
Exiv2::DecodeParamsis referenced here but this header only includes<exiv2/image.hpp>, which (based on the changes shown) does not declareDecodeParams. This is likely to fail compilation for any TU includingunittest_utils.hpp. Fix by including<exiv2/exif.hpp>here, or by adding a forward declarationnamespace Exiv2 { class DecodeParams; }before the function declaration (note: forward declaration is sufficient for a return-by-value declaration, but the definition must still include the full header).
src/xmp.cpp:1- The recursion limit behavior for XMP decoding is now parameterized via
DecodeParams(previously hard-coded). It would be good to add a focused unit test that sets a very smallmax_recursion_depthand assertsXmpParser::decode()fails on a deliberately deep-but-well-formed XML packet, and succeeds with a larger depth. This would catch regressions wheredpis accidentally ignored in the future.
src/xmp.cpp:1 - The recursion limit behavior for XMP decoding is now parameterized via
DecodeParams(previously hard-coded). It would be good to add a focused unit test that sets a very smallmax_recursion_depthand assertsXmpParser::decode()fails on a deliberately deep-but-well-formed XML packet, and succeeds with a larger depth. This would catch regressions wheredpis accidentally ignored in the future.
- Files reviewed: 44/44 changed files
- Comments generated: 4
- Review effort level: Lite
There was a problem hiding this comment.
Review details
Suppressed comments (2)
include/exiv2/params.hpp:8
params.hppusessize_tbut does not include a standard header that defines it. Relying on transitive includes makes this public header non-self-contained and can break downstream builds depending on include order.
// *****************************************************************************
#include "exiv2lib_export.h"
include/exiv2/params.hpp:18
- The doc comment says "Similar to
ImageCtorParamsabove" butImageCtorParamsis not declared in this header. This makes the documentation confusing for readers ofparams.hppin isolation.
@brief Parameters for the "decode" functions. There are a fairly large
number of static "decode" functions. Examples are `ExifParser::decode`,
`TiffParser::decode`, and `XmpParser::decode`. Similar to `ImageCtorParams` above,
this class is a common set of parameters for those functions. It currently
only contains a `max_recursion_depth_` field, but it will make it easier to
- Files reviewed: 45/45 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Tick the box to add this pull request to the merge queue (same as
|
This PR is the next step after #9396. It's plumbing to get the
max_recursion_depthparameter to all the places that it needs to go.I wasn't expecting to have to change this many files. Most of the changes are because I wanted to remove this hard-coded limit:
exiv2/src/xmp.cpp
Line 60 in 74bd423
In order to get the new parameter there, I needed to add a new parameter to all the "decode" functions, which are mostly static class methods.
Similar to #9396, I have tried to future-proof this change by adding a new class named
DecodeParams.