WIP: lowercase all emails when comparing #1109

Draft
Marius wants to merge 6 commits from Marius/Plume:lowercase_emails into main
First-time contributor

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 added 2 commits 2022-07-04 21:24:42 +00:00
Marius added 1 commit 2022-07-04 21:26:49 +00:00
Marius added 3 commits 2022-07-04 21:51:13 +00:00
Author
First-time contributor

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.

Seems nice solution. Thanks!

Seems nice solution. Thanks!

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

Making comparison rule case-insensitive in database is also a solution.
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u lowercase_emails:Marius-lowercase_emails
git checkout Marius-lowercase_emails
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Plume/Plume#1109
No description provided.