Skip to content
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

Handle internationalized domains #27546

Closed
tcitworld opened this issue Jun 17, 2021 · 2 comments
Closed

Handle internationalized domains #27546

tcitworld opened this issue Jun 17, 2021 · 2 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug feature: emails needs info

Comments

@tcitworld
Copy link
Member

Noticed while having a look at #27474

We make use of FILTER_VALIDATE_URL and FILTER_VALIDATE_EMAIL but both don't support internationalized domains (IDNs), which need to be converted to punycode before being validated.

The function should be available in OCP because a few core apps make use of these filters. It should look like the following:

/**
 * @return string | boolean
 */
function validateEmail(string $email) {
  $pos = strrpos($email, '@');
  if ($pos === false) {
    return false;
  }
  $domain = validateDomain(substr($email, $pos + 1));
  if (!$domain) {
    return false;
  }
  $ascii_email = substr($email, 0, $pos) . '@' . $domain;
  return filter_var($ascii_email, FILTER_VALIDATE_EMAIL);
}

/**
 * @return string|boolean
 */
function validateDomain(string $domain) {
  return filter_var(idn_to_ascii($domain), FILTER_VALIDATE_URL);
}
@tcitworld tcitworld added bug 1. to develop Accepted and waiting to be taken care of feature: emails labels Jun 17, 2021
@tcitworld
Copy link
Member Author

OC\Mail\Message and OC\Mail\Mailer already have respectively convertAddresses and convertEmail (which is used by validateMailAddress, so this is already here basically).

CarlSchwan added a commit that referenced this issue Jul 14, 2021
This was recommended in #27546 just not sure Util is the best class.
@szaimen
Copy link
Contributor

szaimen commented Jan 23, 2023

Hi, please update to 24.0.9 or better 25.0.3 and report back if it fixes the issue. Thank you!

My goal is to add a label like e.g. 25-feedback to this ticket of an up-to-date major Nextcloud version where the bug could be reproduced. However this is not going to work without your help. So thanks for all your effort!

If you don't manage to reproduce the issue in time and the issue gets closed but you can reproduce the issue afterwards, feel free to create a new bug report with up-to-date information by following this link: https://github.com/nextcloud/server/issues/new?assignees=&labels=bug%2C0.+Needs+triage&template=BUG_REPORT.yml&title=%5BBug%5D%3A+

@szaimen szaimen added needs info 0. Needs triage Pending check for reproducibility or if it fits our roadmap and removed 1. to develop Accepted and waiting to be taken care of labels Jan 23, 2023
@szaimen szaimen closed this as completed Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug feature: emails needs info
Projects
None yet
Development

No branches or pull requests

2 participants