fix(export): sanitize DOCX relationships and numbering namespaces (SD-3399)#3681
fix(export): sanitize DOCX relationships and numbering namespaces (SD-3399)#3681mattConnHarbour wants to merge 1 commit into
Conversation
…-3399) Fix two issues causing exported DOCX files to require Word repair: 1. Prune dangling relationships in word/_rels/document.xml.rels - Remove references to non-existent parts (e.g., stylesWithEffects.xml) - Preserve external relationships (URLs) regardless of file existence 2. Ensure xmlns:w15 namespace is declared in numbering.xml - Required when w15:restartNumberingAfterBreak attributes are present - Add mc:Ignorable="w15" for forward compatibility Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a493e8bfe
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Target is relative to word/ | ||
| return normalized.startsWith('word/') ? normalized : `word/${normalized}`; |
There was a problem hiding this comment.
Preserve absolute internal relationship targets
For documents whose word/_rels/document.xml.rels uses an absolute internal target such as /word/media/pic.jpg (a form the existing image import path explicitly normalizes and supports), this resolver falls through to word/${normalized} and produces word//word/media/pic.jpg. The new pruning filter then sees fileExists as false and removes the valid relationship, leaving the exported DOCX with drawings or other references still pointing at an rId that no longer exists.
Useful? React with 👍 / 👎.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
word/_rels/document.xml.relsthat reference non-existent parts (e.g.,stylesWithEffects.xmlfrom legacy Word 2010 documents)xmlns:w15namespace is declared innumbering.xmlwhenw15:restartNumberingAfterBreakattributes are present