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

Security and parsing update #300

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions inc/commondbtm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1490,9 +1490,13 @@ function prepareInputForClone($input) {
}

// Try to find an available name
do {
$copy_name = $this->computeCloneName($current_name, ++$copy_index);
} while (countElementsInTable($table, [$name_field => $copy_name]) > 0);
if (!$input['is_template'] || countElementsInTable($table, [$name_field => $current_name]) > 0) {
do {
$copy_name = $this->computeCloneName($current_name, ++$copy_index);
} while (countElementsInTable($table, [$name_field => $copy_name]) > 0);
} else {
$copy_name = $current_name;
}

// Update index cache
$this->last_clone_index = $copy_index;
Expand Down
24 changes: 23 additions & 1 deletion inc/search.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ static function prepareDatasForSearch($itemtype, array $params, array $forcedisp
$p['start'] = 0;
}

$p = self::cleanParams($p);

$data = [];
$data['search'] = $p;
$data['itemtype'] = $itemtype;
Expand Down Expand Up @@ -6755,9 +6757,29 @@ static function manageParams($itemtype, $params = [], $usesession = true,
}
}

return $params;
return self::cleanParams($params);
}

public static function cleanParams(array $params): array
{
$int_params = [
'sort'
];

foreach ($params as $key => &$val) {
if (in_array($key, $int_params)) {
if (is_array($val)) {
foreach ($val as &$subval) {
$subval = (int)$subval;
}
} else {
$val = (int)$val;
}
}
}

return $params;
}

/**
* Clean search options depending of user active profile
Expand Down
Loading