Skip to content

Commit

Permalink
Prevent XSS on Dropdown imports
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne authored and trasher committed Nov 3, 2022
1 parent 0898caa commit 1fe7a87
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/CommonDropdown.php
Expand Up @@ -35,6 +35,7 @@

use Glpi\Application\View\TemplateRenderer;
use Glpi\Features\AssetImage;
use Glpi\Toolbox\Sanitizer;

/// CommonDropdown class - generic dropdown
abstract class CommonDropdown extends CommonDBTM
Expand Down Expand Up @@ -706,6 +707,8 @@ public function import(array $input)
return -1;
}

$input = Sanitizer::sanitize($input);

// Check twin :
if ($ID = $this->findID($input)) {
if ($ID > 0) {
Expand Down Expand Up @@ -744,7 +747,7 @@ public function importExternal(
return 0;
}

$ruleinput = ["name" => stripslashes($value)];
$ruleinput = ["name" => $value];
$rulecollection = RuleCollection::getClassByType($this->getType(), true);

foreach ($this->additional_fields_for_dictionnary as $field) {
Expand All @@ -766,14 +769,14 @@ public function importExternal(
break;
}*/

$input = [
$input = Sanitizer::sanitize([
'name' => $value,
'comment' => $comment,
'entities_id' => $entities_id,
];
]);

if ($rulecollection) {
$res_rule = $rulecollection->processAllRules(Toolbox::stripslashes_deep($ruleinput), [], []);
$res_rule = $rulecollection->processAllRules(Sanitizer::dbUnescapeRecursive($ruleinput), [], []);
if (isset($res_rule["name"])) {
$input["name"] = $res_rule["name"];
}
Expand Down

0 comments on commit 1fe7a87

Please sign in to comment.