WIP: lowercase all emails when comparing #1109

Rascunho
Marius quer mesclar 6 commits de Marius/Plume:lowercase_emails em main
Primeira vez contribuindo

Problem

In #989 , it is described that email should be compared case insensitively.

The RFC 5321 describes that:

The local-part of a mailbox MUST BE treated as case sensitive.
Therefore, SMTP implementations MUST take care to preserve the case
of mailbox local-parts. In particular, for some hosts, the user
"smith" is different from the user "Smith". However, exploiting the
case sensitivity of mailbox local-parts impedes interoperability and
is discouraged. Mailbox domains follow normal DNS rules and are
hence not case sensitive.

In plume, we compare the emails as-is, so case-sensitively, this PR proposes to replace all emails comparisons and search within tables of the form

email.eq(stored_email)
email == stored_email

by

email.to_lowercase().eq(stored_email.to_lowercase())

It is more verbose, but permit to keep the database coherent with what user types (case-sensitive email).

How to find where to modify

I launched the following command in plume repository, on a standard debian to find all files using emails.

grep -rn mail plume-*/* src/* | cut --fields=1,2 --delimiter=: | tee list_of_file | cut --fields=1 --delimiter=: | xargs

Then i just searched for comparisons as previously described and replaced them.

Testing

Launch an instance with that and verify everything works, with email case-insensitive, but that they are still stored case sensitive.

# Problem In #989 , it is described that email should be compared case insensitively. The [RFC 5321](https://datatracker.ietf.org/doc/html/rfc5321#section-2.4) describes that: > The local-part of a mailbox MUST BE treated as case sensitive. Therefore, SMTP implementations MUST take care to preserve the case of mailbox local-parts. In particular, for some hosts, the user "smith" is different from the user "Smith". However, exploiting the case sensitivity of mailbox local-parts impedes interoperability and is discouraged. Mailbox domains follow normal DNS rules and are hence not case sensitive. In plume, we compare the emails as-is, so case-sensitively, this PR proposes to replace all emails comparisons and search within tables of the form ```rust email.eq(stored_email) email == stored_email ``` by ```rust email.to_lowercase().eq(stored_email.to_lowercase()) ``` It is more verbose, but permit to keep the database coherent with what user types (case-sensitive email). # How to find where to modify I launched the following command in plume repository, on a standard debian to find all files using emails. ```bash grep -rn mail plume-*/* src/* | cut --fields=1,2 --delimiter=: | tee list_of_file | cut --fields=1 --delimiter=: | xargs ``` Then i just searched for comparisons as previously described and replaced them. # Testing Launch an instance with that and verify everything works, with email case-insensitive, but that they are still stored case sensitive.
Marius adicionou 2 commits 2022-07-04 21:24:42 +00:00
Marius adicionou 1 commit 2022-07-04 21:26:49 +00:00
Marius adicionou 3 commits 2022-07-04 21:51:13 +00:00
Autor
Primeira vez contribuindo

Right now this don't work, because the lower function seems not implemented in diesel, however i found this discussion Lemmy lower.

They seems to implement it straightforward, but i can't find how to use the same idea without modifying to much.

So waiting for that, and your ideas on this PR.

Right now this don't work, because the lower function seems not implemented in diesel, however i found this discussion [Lemmy lower](https://github.com/LemmyNet/lemmy/pull/2005). They seems to implement it straightforward, but i can't find how to use the same idea without modifying to much. So waiting for that, and your ideas on this PR.
Proprietário(a)

Seems nice solution. Thanks!

Seems nice solution. Thanks!
Proprietário(a)

Making comparison rule case-insensitive in database is also a solution.

Making comparison rule case-insensitive in database is also a solution.
Este pull request está marcado como um trabalho em andamento.
Este branch está desatualizado com o branch base
Ver instruções de linha de comando

Checkout

Do repositório do seu projeto, faça checkout de um novo branch e teste as alterações.
git fetch -u lowercase_emails:Marius-lowercase_emails
git checkout Marius-lowercase_emails
Inicie a sessão para participar desta conversa.
Sem revisor
Sem marco
Sem projeto
Sem responsáveis
2 participantes
Notificações
Data limite
A data limite é inválida ou está fora do intervalo permitido. Por favor, use o formato "yyyy-mm-dd".

Não há data limite definida.

Dependências

Não há dependências definidas.

Referência: Plume/Plume#1109
Nenhuma descrição fornecida.