#27469: Email crashes cryptically when emptystring passed to
django.core.mail.message.sanitize_address
-------------------------------------+-------------------------------------
Reporter: Jarek Glowacki | Owner: nobody
Type: Bug | Status: new
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: sanitize_address | Triage Stage:
mail | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jarek Glowacki):
We don't use `sanitize_addresss` directly, it ends up getting called
during an `email.send()` call on our end.
We have a pretty complex django project that has numerous apps set up to
do some form of emailing. The email 'to' and 'cc' are set by the end user
on a `Contact` model, both fields are allowed to be empty. The system then
builds emails in various configurations, in some cases ccing contacts in
on one email, in other cases creating separate emails per contact. Long
story short the logic is nontrivial.
A couple of times now (usually after rounds of refactoring) we've hit a
case where either the 'to' or 'cc' list contains an emptystring, causing
this cryptic error to surface when `email.send()` is called. Each time
it's been someone else in the office hitting it, consuming a moderate
amount of time to track down the cause.
It would be nice if this raised a proper error, so that we could either
have something nice to catch and handle during runtime, or be able to
quickly understand what's going if it shows up again in our error logs.
Worst of all, this doesn't show up when we test the project locally, as we
swap out the smtp backend with a dummy one in debug mode. So another idea
could maybe be to catch this problem earlier to make it backend-
independent.
This is a non issue for those that are careful and validate email
addresses before trying to call `.send()`, but for those that do fall into
this trap, they probably shouldn't be hit with an unhelpful `IndexError:
string index out of range`.
--
Ticket URL: <https://code.djangoproject.com/ticket/27469#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.f18e57ca607a0425dabddb5a9f909d4c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.