Fix: XML serializer corrupts zero header colour-space signature on round-trip (#1355)#1356
Merged
xsscx merged 1 commit intoJun 15, 2026
Conversation
…und-trip (InternationalColorConsortium#1355) CIccProfileXml::ToXml() wrote the data colour space and PCS header signatures via icGetColorSigStr() unconditionally. For a zero signature (0x00000000) that helper returns the literal text "NULL"; the inverse icGetSigVal("NULL") on reparse packs the ASCII bytes 'N','U','L','L' into 0x4E554C4C, so a NoData header silently became "Unknown 'NULL' = 4E554C4C" after a ToXml -> FromXml round-trip. The JSON serializer (IccProfileJson.cpp:136-137) already guards both fields, emitting "" for a zero signature, which round-trips back to 0 -> "NoData". This is the sole reason iccFromXml and iccFromJson reported different data colour spaces for the same profile (InternationalColorConsortium#1355). Mirror the JSON behaviour: emit an empty element for a zero DataColourSpace / PCS signature. icXmlGetChildSigVal() returns 0 for an empty element, so the value round-trips faithfully. A zero data colour space is itself invalid for a v2/v4 profile per ICC.1 (v4.4.0.0) 7.2.6 / Table 19; preserving the bytes is a serialization concern, leaving the validator to flag the malformance. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 15, 2026
Merged
Closed
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the FromXml/FromJson divergence reported in #1355.
CIccProfileXml::ToXml()serialized the data colour space and PCS header signatures withicGetColorSigStr()unconditionally. For a zero signature (0x00000000) that helper returns the literal textNULL, and the inverseicGetSigVal("NULL")on reparse packs the ASCII bytesN,U,L,Linto0x4E554C4C. ANoDataheader therefore becameUnknown 'NULL' = 4E554C4Cafter aToXml -> FromXmlround-trip.The JSON serializer already guards both fields (
IccProfileJson.cpp:136-137), emitting""for a zero signature, which round-trips back to0->NoData. That guard is the entire reasoniccFromXmlandiccFromJsonreported different data colour spaces for the same profile.Fix
Mirror the JSON behaviour in
IccProfileXml.cpp: emit an empty element for a zeroDataColourSpace/PCSsignature.icXmlGetChildSigVal()already returns0for an empty element, so the value round-trips faithfully.(same guard applied to
<PCS>)Verification
Repro profile:
Testing/hybrid/Results/LCDDisplayCat8Obs.icc(emitted byiccV5DspObsToV4Dsp, header data colour space =NoData/0x00000000).iccToXmlelement<DataColourSpace>NULL</DataColourSpace><DataColourSpace></DataColourSpace>iccFromXmlre-dumpUnknown 'NULL' = 4E554C4CNoDataiccFromJsonre-dump (unchanged)NoDataNoDataRGB/XYZand round-trips intact (no regression).Scope / spec note
A zero data colour space is itself invalid for a v2/v4 profile per ICC.1 (v4.4.0.0) §7.2.6 / Table 19 — this PR does not try to "correct" the malformed profile, only to stop the serializer from corrupting the bytes. Faithful preservation is a serializer concern; flagging the malformance is the validator's job. See the analysis on #1355 for the full spec discussion (including the
"NoData"descriptor and the colorant-tag classification, both tracked separately).A paired regression test PR will follow per the established fix/test split (cf. #1344/#1345).
🤖 Generated with Claude Code