fix: declare c2pa XML namespace on SVG root, not manifest tag#2113
Open
ak-singh wants to merge 2 commits into
Open
fix: declare c2pa XML namespace on SVG root, not manifest tag#2113ak-singh wants to merge 2 commits into
ak-singh wants to merge 2 commits into
Conversation
tmathern
approved these changes
May 8, 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.
Changes in this pull request
Issue
SVG signing was adding the
xmlns:c2panamespace to the<c2pa:manifest>element. Issue #1634 requests that it be declared on the root<svg>element instead.Before this fix:
After this fix:
Fix
xmlns:c2pato the root<svg>element if not already present.xmlns:c2pato new<c2pa:manifest>elements, since the root now has it.Test
Modified three existing tests to assert the new namespace position:
test_write_svg_no_meta,test_write_svg_with_meta, andtest_write_svg_with_manifest.Added two new tests:
test_write_svg_no_metadata_element— covers the Empty arm (sample5).test_write_svg_namespace_idempotent— re-signs and assertsxmlns:c2paisn't duplicated on the root.Verified failing on
mainand passing with the fix.Possible follow-ups
Stripping the inline
xmlns:c2pafrom<c2pa:manifest>when re-signing files that were already signed by older code. Handling this cleanly would require stripping just that attribute while leaving the element's other attributes untouched, which adds unnecessary complexity. The output is still valid XML, and this duplication will naturally decrease over time as more files are signed using the updated implementation. I can include this in the PR if needed.Reducing duplication in
write_cai. The SVG-root check shows up in all three match arms. I kept it inline for visibility, but can pull it into a helper here if preferred. I could also unify the three arms into a single-pass loop. That could go in this PR or a separate one.Checklist
TO DOitems (or similar) have been entered as GitHub issues and the link to that issue has been included in a comment.Closes #1634