Skip to content

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

Open
duckduckgrayduck wants to merge 1 commit into
masterfrom
fix_mailkey_uuid_parsing
Open

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

Conversation

@duckduckgrayduck
Copy link
Copy Markdown
Contributor

@duckduckgrayduck duckduckgrayduck commented Jun 5, 2026

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
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

1 participant