Skip to content

Fix: skip empty <wp:docPr> descr/title attributes for Word 2007 compatibility #3073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025

Conversation

minhbvhp
Copy link
Contributor

Fix: skip empty wp:docPr descr/title attributes for Word 2007 compatibility

Description

This pull request addresses an issue where empty descr="" and title="" attributes were being generated inside <wp:docPr> nodes for image runs. These empty attributes can cause parsing issues in Microsoft Word 2007, which doesn't handle them properly, sometimes leading to rendering errors or failure to open the document.

What’s Changed

  • Updated the logic in DocProperties to skip the inclusion of description (descr) and title attributes when they are empty, null, or undefined.
  • This update ensures that only non-empty values for description and title are included in the generated XML.
  • The fix improves backward compatibility with Microsoft Word 2007 and similar older versions, which had issues with empty attribute values.

Example: XML Output Before and After

Before (current behavior):

<wp:docPr id="1" name="ExampleImage" descr="" title=""/>

After (with this PR):

<wp:docPr id="1" name="ExampleImage"/>

Copy link

codecov bot commented May 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c38d0a2) to head (9df151c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3073   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          291       291           
  Lines         8834      8837    +3     
  Branches      1432      1432           
=========================================
+ Hits          8834      8837    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dolanmiu dolanmiu merged commit 1e6c9e1 into dolanmiu:master May 2, 2025
8 checks passed
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.

2 participants