rearrange custom params validation

This commit is contained in:
FreddleSpl0it 2022-07-14 09:39:24 +02:00
parent cd02483b19
commit 223ba44b61
No known key found for this signature in database
GPG Key ID: 6315227FF33D2425

View File

@ -341,7 +341,13 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
foreach (explode('-', $custom_params) as $param){ foreach (explode('-', $custom_params) as $param){
if(empty($param)) continue; if(empty($param)) continue;
if (str_contains(explode('=', $param)[0], ' ')) { // extract option
if (str_contains($param, '=')) $param = explode('=', $param)[0];
else $param = rtrim($param, ' ');
// remove first char if first char is -
if ($param[0] == '-') $param = ltrim($param, $param[0]);
if (str_contains($param, ' ')) {
// bad char // bad char
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
'type' => 'danger', 'type' => 'danger',
@ -351,11 +357,6 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
return false; return false;
} }
// extract option
if (str_contains($param, '=')) $param = explode('=', $param)[0];
// remove first char if first char is -
if ($param[0] == '-') $param = ltrim($param, $param[0]);
// check if param is whitelisted // check if param is whitelisted
if (!in_array(strtolower($param), $GLOBALS["IMAPSYNC_OPTIONS"]["whitelist"])){ if (!in_array(strtolower($param), $GLOBALS["IMAPSYNC_OPTIONS"]["whitelist"])){
// bad option // bad option
@ -1796,7 +1797,13 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
foreach (explode('-', $custom_params) as $param){ foreach (explode('-', $custom_params) as $param){
if(empty($param)) continue; if(empty($param)) continue;
if (str_contains(explode('=', $param)[0], ' ')) { // extract option
if (str_contains($param, '=')) $param = explode('=', $param)[0];
else $param = rtrim($param, ' ');
// remove first char if first char is -
if ($param[0] == '-') $param = ltrim($param, $param[0]);
if (str_contains($param, ' ')) {
// bad char // bad char
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
'type' => 'danger', 'type' => 'danger',
@ -1806,11 +1813,6 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
return false; return false;
} }
// extract option
if (str_contains($param, '=')) $param = explode('=', $param)[0];
// remove first char if first char is -
if ($param[0] == '-') $param = ltrim($param, $param[0]);
// check if param is whitelisted // check if param is whitelisted
if (!in_array(strtolower($param), $GLOBALS["IMAPSYNC_OPTIONS"]["whitelist"])){ if (!in_array(strtolower($param), $GLOBALS["IMAPSYNC_OPTIONS"]["whitelist"])){
// bad option // bad option