-
Notifications
You must be signed in to change notification settings - Fork 270
fix: normalize email addresses when retrieving from server #11055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
744f0b3
to
7659ee1
Compare
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
a7f06b2
to
24b0191
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐘 did not test
// user1@example.com | ||
// 'user1@example.com' | ||
// ' user1@example.com' | ||
return strtolower(trim(trim($address, "'"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned at #10980 (comment).
'test@example.org
is a valid email address.- The current normalizer incorrectly changes it to
test@example.org
Example:
if (str_starts_with($address, "'") && str_ends_with($address, "'")) {
$address = substr($address, 1, -1); // or trim($address, "'"); whatever you prefer
}
return strtolower(trim($address));
Given that we need the same logic in the repair job, I'd suggest moving the normalization to a small helper or utility service to make it reusable and more testable.
$select->expr()->like('email', $select->createNamedParameter('\'%\'', IQueryBuilder::PARAM_STR)) | ||
) | ||
->setMaxResults(1000); | ||
$recipients = $select->executeQuery()->fetchAll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$recipients = $select->executeQuery()->fetchAll(); | |
$result = $select->executeQuery(); | |
$recipients = $result->fetchAll(); | |
$result->closeCursor(); |
foreach ($recipients as $recipient) { | ||
$id = $recipient['id']; | ||
$email = $recipient['email']; | ||
$email = trim(str_replace('\'', '', (string)$email)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$email = trim(str_replace('\'', '', (string)$email)); | |
$email = trim(trim($email, "'")); |
The best approach would be to reuse the logic from the address class. If we don't go with the helper/utility, we should still use trim to remove the first and last character (even if we can be very sure, due to the query, that we're only dealing with emails starting and ending with a '
).
resolves: client ticket - issue with email addresses being wrapped in single quotes