Skip to content

Add better parsing of email addresses and add tests for mailgun#407

Merged
duckduckgrayduck merged 1 commit into
masterfrom
fix_mailkey_uuid_parsing
Jun 8, 2026
Merged

Add better parsing of email addresses and add tests for mailgun#407
duckduckgrayduck merged 1 commit into
masterfrom
fix_mailkey_uuid_parsing

Conversation

@duckduckgrayduck

@duckduckgrayduck duckduckgrayduck commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Our previous logic took everything before the first @, which in some cases would include a leading quotation mark " (depending I guess on the email server sending it) like:

""uuid@uploads.documentcloud.org" uuid@uploads.documentcloud.org"
in the To field. This PR moves us to use a more robust and built in email parsing email.utils.parseaddr which will handle those leading quotes automatically, as well as < and other possible symbols. It also automatically rejects malformed inputs for safety.

This PR also raises ValidationErrors in case parseaddr somehow doesn't catch anything and adds some tests for mailgun since there were none. I had Claude write the tests because they are boilerplate.

Closes #406

@duckduckgrayduck duckduckgrayduck force-pushed the fix_mailkey_uuid_parsing branch from e2aa7c1 to 7246911 Compare June 5, 2026 15:08
@duckduckgrayduck duckduckgrayduck merged commit 003ded3 into master Jun 8, 2026
3 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.

Fix stripping mailkey from email headers coming from mailgun

2 participants