Skip to content

fix(email): exclude inline Outlook resources from attachment lists - #5425

Open
Christiansada wants to merge 1 commit into
docling-project:mainfrom
Christiansada:fix/msg-inline-attachments
Open

Christiansada wants to merge 1 commit into
docling-project:mainfrom
Christiansada:fix/msg-inline-attachments

Conversation

@Christiansada

Copy link
Copy Markdown

An Outlook signature image currently becomes an ordinary MIME attachment during .msg conversion. With list_attachments=True, its filename then appears beside real attachments in the exported document.

This filters hidden MAPI attachments and content IDs referenced by HTML src, href, background, or data URLs before creating MIME placeholders. Unreferenced content IDs and ordinary image attachments remain listed. URI escapes are decoded and IDs are matched exactly. Attachment payloads are never read. The HTML parser stays a lazy import to preserve minimal-install compatibility.

Fixes #5416. Thanks to the reporter for identifying the MAPI properties; their private emails were not used.

Checklist:

  • Documentation updated with the precise filtering scope.
  • Examples added (not needed for the existing option).
  • Regression tests added.

Review evidence:

  • On unchanged main e16c4b71a7b7d9154ffca164accad2581aed5c9f, the final regression file reports 9 failed, 9 passed. Referenced and hidden attachments remain in the generated MIME list.
  • The tests use real python-oxmsg property decoding with synthetic MAPI storage. Only the CFB loader boundary is replaced. They check MIME filenames, the Docling attachment list and its parents, Markdown output, retained real attachments and a failing guard against attachment payload reads.
  • uv run --no-sync pytest -q -rs tests/test_backend_email_inline_attachments.py tests/test_backend_email.py tests/test_backend_html.py tests/test_backend_calendar.py tests/test_backend_optional_dependencies.py tests/test_input_doc.py: 342 passed, 1 skipped (4 warnings). The skipped HTML rendering test requires optional Playwright, which is not installed.
  • UV_NO_SYNC=1 make validate: all applicable hooks passed, including Ruff, formatter, ty, Tach and module coverage. git diff --check passed.
  • Environment: Python 3.12.14, macOS 26.6.2 arm64, docling-slim 2.150.1, docling-core 2.106.0, python-oxmsg 0.0.2, mail-parser 4.8.0. Dependencies were synced from the frozen lockfile with the standard conversion extra and dev group. The unrelated all-extras setup failed building the video dependency webrtcvad; no dependency/configuration files were changed.

Limits: local macOS arm64/Python 3.12 validation. No reporter-original files or collection-wide results are claimed. CSS url() and srcset CID references are outside this change; the supported URL attributes are documented. No reference data was regenerated. Full model/OCR/live-service tests were not run.

@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @Christiansada, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working email issue related to email (EML, MSG) backend priority:low labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit c4deb9123a. The analysis read the diff only. It did not run code from this pull request.

The PR changes .msg conversion so that hidden MAPI attachments are no longer listed as attachments. It also hides inline resources that the HTML body references with cid: URLs. Real attachments stay in the list. The PR adds tests and a documentation note.

Topic labels added: bug, email, priority:low.

CI safety: no concern found. A maintainer must still approve CI.

1 related pull request(s) in the same code
PR State Signal Assessment
#5420 open changes the same code related: Both PRs change _msg_to_rfc822_bytes in email_backend.py. PR 5420 fixes the sender display name for Exchange senders. This PR filters inline attachments. The two fixes do not conflict in purpose.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI first review (advisory): no blocker found

This review covers the full diff at c4deb9123a. It read the code and did not run it.

Checked Outlook .msg attachment filtering for hidden MAPI properties and HTML cid: references. Verified that attachment payloads are not read, unreferenced attachments remain listed, and minimal installations remain functional.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Nov 16, 2026
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

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

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working email issue related to email (EML, MSG) backend priority:low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Email backend lists inline images (signature logos) as attachments for .msg files

1 participant