| 1 |
Email |
| 2 |
===== |
| 3 |
|
| 4 |
Case Sensitivity |
| 5 |
**************** |
| 6 |
|
| 7 |
Historically, email addresses started out as case sensitive because the local |
| 8 |
part (the part before the "@") could represent a case sensitive user |
| 9 |
name. However, over time, this proved to be a bad idea and the RFCs that |
| 10 |
succeeded the original were adjusted to move away from treating email addresses |
| 11 |
as case sensitive. |
| 12 |
|
| 13 |
- `RFC 821 <https://tools.ietf.org/html/rfc821>`_: The original RFC from 1982 |
| 14 |
relies on case sensitivity. |
| 15 |
|
| 16 |
- `RFC 2821 <https://tools.ietf.org/html/rfc2821>`_: Released in 2001, obsoletes |
| 17 |
RFC 821, yet, is still case sensitive. |
| 18 |
|
| 19 |
- `RFC 5321 <https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2>`_: In |
| 20 |
2008, the "Local-part" is weakened to "MAY be case-sensitive". |
| 21 |
|
| 22 |
- `RFC 6530 <https://tools.ietf.org/html/rfc6530#section-10.1>`_: In 2012, the |
| 23 |
following is acknowledged: |
| 24 |
|
| 25 |
It has long been the case that the email syntax permits choices about |
| 26 |
mailbox names that are **unwise in practice** [...]. The most often cited |
| 27 |
examples involve the use of **case-sensitivity** [...] in mailbox local |
| 28 |
parts. These deliberately unusual constructions **are permitted** by the |
| 29 |
protocols, and servers are expected to support them. Although they can |
| 30 |
provide value in special cases, taking advantage of them **is almost always |
| 31 |
bad practice** unless the intent is to create some form of **security by |
| 32 |
obscurity**. |
| 33 |
|
| 34 |
To deal with this, previous versions of django-allauth used to store email |
| 35 |
addresses in their original case, while performing lookups in a case insensitive |
| 36 |
style. This approach led to subtle bugs in upstream code, and also comes at a |
| 37 |
performance cost (``__iexact`` lookups). The latter requires case insensitive |
| 38 |
index support, which not all databases support. Re-evaluating the approach in |
| 39 |
current times has led to the conclusion that the benefits do not outweigh the |
| 40 |
costs. Therefore, email addresses are now always stored as lower case. |