diff --git a/data/web/inc/footer.inc.php b/data/web/inc/footer.inc.php index 3c92c28e..d0932514 100644 --- a/data/web/inc/footer.inc.php +++ b/data/web/inc/footer.inc.php @@ -61,7 +61,7 @@ $(document).ready(function() { type: "GET", cache: false, dataType: 'script', - url: "/api/v1/get/u2f-authentication/= (isset($_SESSION['pending_mailcow_cc_username'])) ? $_SESSION['pending_mailcow_cc_username'] : null; ?>", + url: "/api/v1/get/u2f-authentication/= (isset($_SESSION['pending_mailcow_cc_username'])) ? rawurlencode($_SESSION['pending_mailcow_cc_username']) : null; ?>", complete: function(data){ $('#u2f_status_auth').html('=$lang['tfa']['waiting_usb_auth'];?>'); data; @@ -100,7 +100,7 @@ $(document).ready(function() { type: "GET", cache: false, dataType: 'script', - url: "/api/v1/get/u2f-registration/= (isset($_SESSION['mailcow_cc_username'])) ? $_SESSION['mailcow_cc_username'] : null; ?>", + url: "/api/v1/get/u2f-registration/= (isset($_SESSION['mailcow_cc_username'])) ? rawurlencode($_SESSION['mailcow_cc_username']) : null; ?>", complete: function(data){ data; setTimeout(function() { diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php index f4e8d039..92f4da2b 100644 --- a/data/web/inc/functions.inc.php +++ b/data/web/inc/functions.inc.php @@ -39,7 +39,7 @@ function hasDomainAccess($username, $role, $domain) { } function hasMailboxObjectAccess($username, $role, $object) { global $pdo; - if (!filter_var($username, FILTER_VALIDATE_EMAIL) && !ctype_alnum(str_replace(array('_', '.', '-'), '', $username))) { + if (!filter_var(html_entity_decode(rawurldecode($username)), FILTER_VALIDATE_EMAIL) && !ctype_alnum(str_replace(array('_', '.', '-'), '', $username))) { return false; } if ($role != 'admin' && $role != 'domainadmin' && $role != 'user') { @@ -471,22 +471,18 @@ function user_get_alias_details($username) { )); $run = $stmt->fetchAll(PDO::FETCH_ASSOC); while ($row = array_shift($run)) { - $data['direct_aliases'] = $row['direct_aliases']; + $data['direct_aliases'][] = $row['direct_aliases']; } - $stmt = $pdo->prepare("SELECT IFNULL(GROUP_CONCAT(local_part, '@', alias_domain SEPARATOR ', '), '✘') AS `ad_alias` FROM `mailbox` + $stmt = $pdo->prepare("SELECT GROUP_CONCAT(local_part, '@', alias_domain SEPARATOR ', ') AS `ad_alias` FROM `mailbox` LEFT OUTER JOIN `alias_domain` on `target_domain` = `domain` WHERE `username` = :username ;"); $stmt->execute(array(':username' => $username)); $run = $stmt->fetchAll(PDO::FETCH_ASSOC); while ($row = array_shift($run)) { - if (empty($data['direct_aliases'])) { - $data['direct_aliases'] = $row['ad_alias']; - } - else { - // Probably faster than imploding - $data['direct_aliases'] .= ', ' . $row['ad_alias']; - } + $data['direct_aliases'][] = $row['ad_alias']; } + $data['direct_aliases'] = implode(', ', array_filter($data['direct_aliases'])); + $data['direct_aliases'] = empty($data['direct_aliases']) ? '✘' : $data['direct_aliases']; $stmt = $pdo->prepare("SELECT IFNULL(GROUP_CONCAT(`send_as` SEPARATOR ', '), '✘') AS `send_as` FROM `sender_acl` WHERE `logged_in_as` = :username AND `send_as` NOT LIKE '@%';"); $stmt->execute(array(':username' => $username)); $run = $stmt->fetchAll(PDO::FETCH_ASSOC); diff --git a/data/web/inc/functions.policy.inc.php b/data/web/inc/functions.policy.inc.php index 9609d5e1..63f178c1 100644 --- a/data/web/inc/functions.policy.inc.php +++ b/data/web/inc/functions.policy.inc.php @@ -94,7 +94,7 @@ function policy($_action, $_scope, $_data = null) { if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $object)) { $_SESSION['return'] = array( 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) + 'msg' => $object ); return false; } diff --git a/data/web/inc/header.inc.php b/data/web/inc/header.inc.php index 253692fc..0c516d39 100644 --- a/data/web/inc/header.inc.php +++ b/data/web/inc/header.inc.php @@ -1,4 +1,4 @@ - +
@@ -129,11 +129,11 @@ } if (!isset($_SESSION['dual-login']) && isset($_SESSION['mailcow_cc_username'])): ?> -' + item.exclude + '
';
}
- item.server_w_port = item.user1 + '@' + item.host1 + ':' + item.port1;
+ item.server_w_port = escapeHtml(item.user1) + '@' + item.host1 + ':' + item.port1;
item.action = '' + item.exclude + '
';
+ item.exclude = '' + escapeHtml(item.exclude) + '
';
}
- item.server_w_port = item.user1 + '@' + item.host1 + ':' + item.port1;
+ item.server_w_port = escapeHtml(item.user1 + '@' + item.host1 + ':' + item.port1);
if (acl_data.syncjobs === 1) {
item.action = '';
item.chkbox = '';
}
@@ -238,7 +240,7 @@ jQuery(function($){
$('#user_sieve_filter').text(lang.loading);
$.ajax({
dataType: 'json',
- url: '/api/v1/get/active-user-sieve/' + mailcow_cc_username,
+ url: '/api/v1/get/active-user-sieve/' + encodeURIComponent(mailcow_cc_username),
jsonp: false,
error: function () {
console.log('Cannot get active sieve script');
diff --git a/data/web/user.php b/data/web/user.php
index 0fb0875f..6b807945 100644
--- a/data/web/user.php
+++ b/data/web/user.php
@@ -164,21 +164,21 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
@@ -201,14 +201,14 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
@@ -225,7 +225,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
=$lang['user']['eas_reset_help'];?>