Skip to content

Print nested XMP properties through their own print function - #9489

Open
jadhavgaurav wants to merge 1 commit into
Exiv2:mainfrom
jadhavgaurav:fix-xmp-nested-print
Open

Print nested XMP properties through their own print function#9489
jadhavgaurav wants to merge 1 commit into
Exiv2:mainfrom
jadhavgaurav:fix-xmp-nested-print

Conversation

@jadhavgaurav

Copy link
Copy Markdown
Contributor

Problem

exiv2 -px prints the raw value of a nested XMP property even when that property has a print function registered.

The report is about the two PLUS licensor telephone types, which are the only PLUS fields that are both subfields of a structure and use a controlled vocabulary:

$ exiv2 -px -g LicensorTelephoneType test/data/issue_1959_poc.xmp
Xmp.plus.Licensor[1]/plus:LicensorTelephoneType1 XmpText    36  http://ns.useplus.org/ldf/vocab/work
Xmp.plus.Licensor[1]/plus:LicensorTelephoneType2 XmpText    36  http://ns.useplus.org/ldf/vocab/cell

Cause

XmpProperties::printPropertyUnlocked() looks the print function up in xmpPrintInfo by the full key. A nested property is keyed by its path (Xmp.plus.Licensor[1]/plus:LicensorTelephoneType1), and the table holds plain property keys (Xmp.plus.LicensorTelephoneType1), so the lookup never matches and printValue is used. Top level PLUS fields such as Xmp.plus.ModelReleaseStatus are unaffected and already print translated.

Fix

If the direct lookup fails and the key is a path, retry with the key of the innermost path element. That is the same element XmpProperties::propertyInfoUnlocked() already resolves a nested key to when it looks up the property definition, so the print function and the property definition now agree on which element a nested key describes.

After the change:

Xmp.plus.Licensor[1]/plus:LicensorTelephoneType1 XmpText    36  Work
Xmp.plus.Licensor[1]/plus:LicensorTelephoneType2 XmpText    36  Cell

Tests

New system test tests/bugfixes/github/test_issue_3332.py, using the existing sample test/data/issue_1959_poc.xmp, which already carries both values. It fails before the change and passes after (verified by reverting the source change, rebuilding and re-running).

One reference file changes, and the change is the fix itself: test/data/test_reference_files/issue_1959_poc.xmp.out lines 198 and 199 now show Work and Cell in the interpreted column. No other reference output in the tree changes, so no other nested key currently resolves to a property that has a print function.

Local results: unit_tests 370/370, bugfixes 325 pass and 10 skipped, regression_tests 329 pass, tiff_test 1 pass, bash_tests 66/67 and lens_tests 1/2. The two failures (io_test, test_canon_lenses) reproduce identically on unmodified main in this build, which has network support off. clang-format is not installed here, so the new code was hand matched to the surrounding style rather than tool checked.

Fixes #3332

XmpProperties::printProperty() looked the print function up by the full
key of the property. A nested property is keyed by its path, for example
Xmp.plus.Licensor[1]/plus:LicensorTelephoneType1, so the lookup never
matched and the raw value was printed. For the two PLUS licensor
telephone types that means the controlled vocabulary URL was shown
instead of the translated label.

Fall back to the key of the innermost path element, which is the same
element XmpProperties::propertyInfo() already resolves a nested key to.

Fixes Exiv2#3332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XMP PLUS LicensorTelephoneType1,2 values are printed not translated

1 participant