Repository navigation
fix(email): drop the empty entry of an address group - #4576
Conversation
An RFC 5322 group with no members, such as "To: undisclosed-recipients:;",
comes back from email.utils.getaddresses() as ("", ""), so sent_to,
cc_recipient and bcc_recipient held [""]. Drop entries without an address
in one helper used by all four address properties.
Signed-off-by: Christopher Krah <[email protected]>
cragwolfe
left a comment
There was a problem hiding this comment.
Reviewed 88de740fc05a50ab1d00df238489459e2753a5b1 with GPT Pro. No actionable code defects or material missing coverage found. Empty-address filtering preserves the formatting and order of retained mailboxes, and the serialized-message regression test covers empty groups alongside a populated group.
This is a code-review approval. GitHub currently reports merge conflicts with main. Required checks changelog, test_dockerfile, lint (3.12), test_unit (3.12), and test_ingest_src (3.12) have no results for this head, and no GitHub Actions runs are listed for it. The Socket project report succeeded and pull request alerts are neutral; these do not establish test success. Resolve the conflicts and obtain the required CI results before merging. No tests were run locally for this review.
(authored by codex)
Drops the `-dev6` suffix so 0.27.34 can be tagged and published. There are no code changes. Since 0.27.33, this release contains: - Free decode buffers sooner when restoring original elements (Unstructured-IO#4524) - Free image buffers sooner during figure extraction (Unstructured-IO#4523) - Honor `encoding=` in `partition_json` and `partition_ndjson` (Unstructured-IO#4483) - Read a PowerPoint line break as a newline (Unstructured-IO#4571) - Drop the empty entry of an email address group (Unstructured-IO#4576) - Read CSV and TSV cells as the file holds them (Unstructured-IO#4574) - Classify text as an email address only when all of it is one (Unstructured-IO#4577) After merge, create the `0.27.34` GitHub release from the merge commit. That publishes to PyPI. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/Unstructured-IO/unstructured/pull/4582?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
partition_email()reportsTo: undisclosed-recipients:;assent_to=[""]. This change drops entries without an address and givesNone, as a missing header does.That header is an RFC 5322 group with no members, which mail clients write whenever every recipient is in Bcc.
email.utils.getaddresses()returns it as("", ""), and the four address properties inemail.pyformat that pair into an empty string.cc_recipientandbcc_recipientdo the same:One helper,
_format_addresses(), now drops entries without an address for all four properties, and returnsNonewhen none are left, as a missing header already does. A group with members keeps only their addresses. The filter also covers a header that the strict parser in Python 3.12.3 rejects, such as[email protected] <[email protected]>. It also comes back as("", ""), so it givesNonenow, as in #4407. CHANGELOG entry under 0.27.31, with the version bumped.Testing
No issue exists for this. #4407 dropped the same empty entries inside a larger parser fallback and was closed by its author before review. This is only that filter, on the code #4543 left. @cragwolfe, you merged #4543 on these properties. I picked
Noneover[]because a missing header already givesNone, so callers test one value. Say if[]fits better and I will switch it.