Repository navigation
fix: find core and extended properties through the root relationships (#457) - #459
Merged
Merged
Conversation
…#457) OPC locates the core-properties part through the package-root relationship of that type; `/docProps/core.xml` is only the name the reference desktop app gives it. Looking the part up by that fixed name made getCoreProperties return null for packages that store it elsewhere, and setCoreProperties then bootstrapped a second part and a second core-properties relationship, which OPC forbids. The extended-properties helpers had the same fixed-name lookup for `/docProps/app.xml`. All four helpers now resolve the part from the root relationships. When setCoreProperties bootstraps, it replaces a part already sitting at `/docProps/core.xml` that no relationship points at, and drops a core-properties relationship whose target part is missing, so the package always ends up with exactly one. Closes #457 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ling relationship Also prefer the core-properties relationship whose part exists when an invalid package holds several. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
getCoreProperties/setCorePropertiesandgetExtendedProperties/setExtendedPropertiesnow find their parts through the package-root relationships instead of the fixed names/docProps/core.xmland/docProps/app.xml. Packages that store core properties elsewhere (for examplepackage/services/metadata/core-properties/<guid>.psmdcp) previously read as having no properties, and setting them added a second core-properties part and relationship.Motivation
Reported with a reproduction in #457. OPC (ECMA-376 Part 2) locates the core-properties part by the root relationship of type
…/metadata/core-properties, and a package may have at most one; the part name is up to the producer.Closes #457
Changes
/docProps/core.xmlthat no relationship points at is no longer treated as the core properties.setCorePropertieshas to bootstrap, it replaces such an unlinked/docProps/core.xmlinstead of failing on the name clash, and drops a core-properties relationship whose target part is missing, so the package ends with exactly one relationship and one[Content_Types].xmloverride (a stale override for a missing part used to be duplicated).../…) throws, as it already does for every other relationship the library resolves.setExtendedPropertiesstill throws when there is no extended-properties part; the message no longer names/docProps/app.xml.resolveTargetacceptsPACKAGE_ROOTas the source for package-root relationships.Testing
test/issue-457-core-properties-rel.test.ts: the issue's reproduction (read + update a moved part, one relationship, no new/docProps/core.xml, validator clean), an absolute relationship target, movedapp.xml, an unlinked/docProps/core.xml, a dangling core-properties relationship (one override afterwards), and several relationships with the first dangling. All fail onmain.pnpm typecheck && pnpm lint && pnpm format:check && pnpm test, pluspnpm --filter @office-kit/pptx-editor test.Breaking changes
None. Packages written by this library or the reference desktop app use
/docProps/*.xmlwith a matching relationship and behave as before.Checklist
flagged it above.
comments.
PR represents real work that warrants a maintainer's review, and I am
willing to defend each line in review.
🤖 Generated with Claude Code