Skip to content

Commit 9503aef

Browse files
committed
use idn_decode for mailuser and login fails for mail-users with IDN domains (Fixes #6021)
1 parent 10e8ecc commit 9503aef

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

interface/web/login/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
if(count($_POST) > 0) {
5959

6060
//** Check variables
61-
if(!preg_match("/^[\w\.\-\_\@]{1,128}$/", $_POST['username'])) $error = $app->lng('user_regex_error');
61+
if(!preg_match("/^[\w\.\-\_\@]{1,128}$/", $app->functions->idn_encode($_POST['username']))) $error = $app->lng('user_regex_error');
6262
if(!preg_match("/^.{1,256}$/i", $_POST['password'])) $error = $app->lng('pw_error_length');
6363

6464
//** importing variables
@@ -152,7 +152,7 @@
152152
if(stristr($username, '@')) {
153153
//* mailuser login
154154
$sql = "SELECT * FROM mail_user WHERE login = ? or email = ?";
155-
$mailuser = $app->db->queryOneRecord($sql, $username, $username);
155+
$mailuser = $app->db->queryOneRecord($sql, $username, $app->functions->idn_encode($username));
156156
$user = false;
157157
if($mailuser) {
158158
$saved_password = stripslashes($mailuser['password']);

interface/web/mailuser/index.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//* Check permissions for module
66
$app->auth->check_module_permissions('mailuser');
77

8-
$app->uses('tpl');
8+
$app->uses('tpl, functions');
99

1010
$app->tpl->newTemplate('form.tpl.htm');
1111
$app->tpl->setInclude('content_tpl', 'templates/index.htm');
@@ -28,8 +28,10 @@
2828

2929
if($rec['cc'] == '') $rec['cc'] = $wb['none_txt'];
3030

31-
$app->tpl->setVar($rec);
31+
$rec['email'] = $app->functions->idn_decode($rec['email']);
32+
$rec['login'] = $app->functions->idn_decode($rec['login']);
3233

34+
$app->tpl->setVar($rec);
3335
$sql2 = "SELECT * FROM server WHERE server_id = ?";
3436
$rec2 = $app->db->queryOneRecord($sql2, $rec['server_id']);
3537

interface/web/mailuser/mail_user_cc_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function onShowEnd() {
7575
global $app, $conf;
7676

7777
$rec = $app->tform->getDataRecord($this->id);
78-
$app->tpl->setVar("email", $rec['email'], true);
78+
$app->tpl->setVar("email", $app->functions->idn_decode($rec['email']), true);
7979

8080
parent::onShowEnd();
8181
}

interface/web/mailuser/mail_user_password_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function onShowEnd() {
6363
global $app, $conf;
6464

6565
$rec = $app->tform->getDataRecord($_SESSION['s']['user']['mailuser_id']);
66-
$app->tpl->setVar("email", $rec['email'], true);
66+
$app->tpl->setVar("email", $app->functions->idn_decode($rec['email']), true);
6767

6868
parent::onShowEnd();
6969
}

interface/web/mailuser/mail_user_spamfilter_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function onShowEnd() {
112112
global $app, $conf;
113113

114114
$rec = $app->tform->getDataRecord($this->id);
115-
$app->tpl->setVar("email", $rec['email'], true);
115+
$app->tpl->setVar("email", $app->functions->idn_decode($rec['email']), true);
116116

117117
// Get the spamfilter policys for the user
118118
$tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = ?", $rec['email']);

0 commit comments

Comments
 (0)