public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
Fix error when adding alias with multiple alias addresses
cbfe5e87
data/web/inc/functions.mailbox.inc.php | 68 ++++++++++++++++------------------
1 file changed, 32 insertions(+), 36 deletions(-)
Diff
diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index 7d5f893f..597d9d87 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -315,10 +315,42 @@ function mailbox($_action, $_type, $_data = null) {
);
return false;
}
+ foreach ($gotos as &$goto) {
+ if (empty($goto)) {
+ continue;
+ }
+ $goto_domain = idn_to_ascii(substr(strstr($goto, '@'), 1));
+ $goto_local_part = strstr($goto, '@', true);
+ $goto = $goto_local_part.'@'.$goto_domain;
+ $stmt = $pdo->prepare("SELECT `username` FROM `mailbox`
+ WHERE `kind` REGEXP 'location|thing|group'
+ AND `username`= :goto");
+ $stmt->execute(array(':goto' => $goto));
+ $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
+ if ($num_results != 0) {
+ $_SESSION['return'] = array(
+ 'type' => 'danger',
+ 'msg' => sprintf($lang['danger']['goto_invalid'])
+ );
+ return false;
+ }
+ if (!filter_var($goto, FILTER_VALIDATE_EMAIL) === true) {
+ $_SESSION['return'] = array(
+ 'type' => 'danger',
+ 'msg' => sprintf($lang['danger']['goto_invalid'])
+ );
+ return false;
+ }
+ }
+ $gotos = array_filter($gotos);
+ $goto = implode(",", $gotos);
foreach ($addresses as $address) {
if (empty($address)) {
continue;
}
+ if (in_array($address, $gotos)) {
+ continue;
+ }
$stmt = $pdo->prepare("SELECT `address` FROM `alias`
WHERE `address`= :address");
$stmt->execute(array(':address' => $address));
@@ -397,42 +429,6 @@ function mailbox($_action, $_type, $_data = null) {
);
return false;
}
- foreach ($gotos as &$goto) {
- if (empty($goto)) {
- continue;
- }
- $goto_domain = idn_to_ascii(substr(strstr($goto, '@'), 1));
- $goto_local_part = strstr($goto, '@', true);
- $goto = $goto_local_part.'@'.$goto_domain;
- $stmt = $pdo->prepare("SELECT `username` FROM `mailbox`
- WHERE `kind` REGEXP 'location|thing|group'
- AND `username`= :goto");
- $stmt->execute(array(':goto' => $goto));
- $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
- if ($num_results != 0) {
- $_SESSION['return'] = array(
- 'type' => 'danger',
- 'msg' => sprintf($lang['danger']['goto_invalid'])
- );
- return false;
- }
- if (!filter_var($goto, FILTER_VALIDATE_EMAIL) === true) {
- $_SESSION['return'] = array(
- 'type' => 'danger',
- 'msg' => sprintf($lang['danger']['goto_invalid'])
- );
- return false;
- }
- if ($goto == $address) {
- $_SESSION['return'] = array(
- 'type' => 'danger',
- 'msg' => sprintf($lang['danger']['alias_goto_identical'])
- );
- return false;
- }
- }
- $gotos = array_filter($gotos);
- $goto = implode(",", $gotos);
try {
$stmt = $pdo->prepare("INSERT INTO `alias` (`address`, `goto`, `domain`, `active`)
VALUES (:address, :goto, :domain, :active)");