Issue 146: Fix comma in encoded address header #147
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #146
Bug Fix
This change resolves the parsing error for address headers (like
From:) that contain an encoded comma. The fix is to parse the raw header withemail.utils.getaddressesbefore decoding withdecode_header_part. This ensures the parser treats the encoded word as a single unit and doesn't split it.Test Correction (for #136)
While implementing this fix, I discovered an issue with
test_issue_136. The test was expecting the following output:[("", "notificaccion-clientes@bbva.mx"), ("", "notificaccion-clientes@bbva.mx"),]I would argue that this is incorrect. The raw From header in that test file is:
From: =?UTF-8?B?bm90aWZpY2FjY2lvbi1jbGllbnRlc0BiYnZhLm14?= <notificaccion-clientes@bbva.mx>This header represents only one address, where the display name is just the encoded version of the email address. The parser correctly decodes the name, sees it's identical to the email, and returns an empty string for the name.
I have updated the test to expect the correct, single-address output:
[("", "notificaccion-clientes@bbva.mx"),]Let me know what you think.