Skip to content

Fix core properties namespace conflict - #657

Open
JackSpiece wants to merge 1 commit into
elapouya:masterfrom
JackSpiece:471-preserve-core-properties-namespace
Open

Fix core properties namespace conflict#657
JackSpiece wants to merge 1 commit into
elapouya:masterfrom
JackSpiece:471-preserve-core-properties-namespace

Conversation

@JackSpiece

Copy link
Copy Markdown

Summary

Importing docxtpl also imports docxcompose when the subdocument extra is installed. docxcompose.utils changes the process-wide python-docx nsmap["cp"] entry to the custom-properties namespace. Later core-property assignments then append an element in that namespace instead of updating the existing core property.

This restores the standard core-properties mapping after the docxcompose imports. docxcompose keeps its own NS mapping, so its custom-property and subdocument behavior is unchanged.

The regression test renders a template, sets keywords, then inspects docProps/core.xml and verifies there is exactly one keyword element in the standard core-properties namespace.

Fixes #471

Verification

  • All 37 repository test scripts pass individually
  • Full flake8 target passes
  • Source distribution and wheel build successfully
  • Core-property, custom-property, and subdocument smoke tests pass with docxcompose 1.4.1 and 2.2.0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docxtpl generates broken docx if some core_properties was changed

1 participant