Skip to content

fix(export): sanitize DOCX relationships and numbering namespaces (SD-3399)#3681

Open
mattConnHarbour wants to merge 1 commit into
mainfrom
SD-3399
Open

fix(export): sanitize DOCX relationships and numbering namespaces (SD-3399)#3681
mattConnHarbour wants to merge 1 commit into
mainfrom
SD-3399

Conversation

@mattConnHarbour

@mattConnHarbour mattConnHarbour commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Prune dangling relationships in word/_rels/document.xml.rels that reference non-existent parts (e.g., stylesWithEffects.xml from legacy Word 2010 documents)
  • Ensure xmlns:w15 namespace is declared in numbering.xml when w15:restartNumberingAfterBreak attributes are present
  • Fixes exported DOCX files requiring Word repair before opening

…-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>
@mattConnHarbour mattConnHarbour requested a review from a team as a code owner June 8, 2026 18:41
@linear-code

linear-code Bot commented Jun 8, 2026

Copy link
Copy Markdown

SD-3399

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +87 to +88
// Target is relative to word/
return normalized.startsWith('word/') ? normalized : `word/${normalized}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants