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

Fix #2752 - Allow domain recipients for address rewrite #6155

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions data/web/inc/functions.address_rewriting.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,13 @@ function recipient_map($_action, $_data = null, $attr = null) {
);
return false;
}
if (!filter_var($new_dest, FILTER_VALIDATE_EMAIL)) {
if (is_valid_domain_name($new_dest)) {
$new_dest_sane = '@' . idn_to_ascii($new_dest, 0, INTL_IDNA_VARIANT_UTS46);
}
elseif (filter_var($new_dest, FILTER_VALIDATE_EMAIL)) {
$new_dest_sane = $new_dest;
}
else {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_action, $_data, $_attr),
Expand All @@ -308,7 +314,7 @@ function recipient_map($_action, $_data = null, $attr = null) {
(:old_dest, :new_dest, :active)");
$stmt->execute(array(
':old_dest' => $old_dest_sane,
':new_dest' => $new_dest,
':new_dest' => $new_dest_sane,
':active' => $active
));
$_SESSION['return'][] = array(
Expand Down Expand Up @@ -351,7 +357,13 @@ function recipient_map($_action, $_data = null, $attr = null) {
);
continue;
}
if (!filter_var($new_dest, FILTER_VALIDATE_EMAIL)) {
if (is_valid_domain_name($new_dest)) {
$new_dest_sane = '@' . idn_to_ascii($new_dest, 0, INTL_IDNA_VARIANT_UTS46);
}
elseif (filter_var($new_dest, FILTER_VALIDATE_EMAIL)) {
$new_dest_sane = $new_dest;
}
else {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_action, $_data, $_attr),
Expand All @@ -378,7 +390,7 @@ function recipient_map($_action, $_data = null, $attr = null) {
WHERE `id`= :id");
$stmt->execute(array(
':old_dest' => $old_dest_sane,
':new_dest' => $new_dest,
':new_dest' => $new_dest_sane,
':active' => $active,
':id' => $id
));
Expand Down