Skip to content
Merged
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed

- fix escape SQL values

## [2.15.6] - 2026-05-05

### Fixed
Expand Down
20 changes: 10 additions & 10 deletions inc/commoninjectionlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1903,7 +1903,7 @@ private function dataAlreadyInDB($injectionClass, $itemtype)
//If it's a computer device
if ($item instanceof CommonDevice) {
$sql .= " WHERE `designation` = '" .
$this->getValueByItemtypeAndName($itemtype, 'designation') . "'";
$DB->escape($this->getValueByItemtypeAndName($itemtype, 'designation')) . "'";
} elseif ($item instanceof CommonDBRelation) {
//Type is a relation : check it this relation still exists
//Define the side of the relation to use
Expand All @@ -1920,13 +1920,13 @@ private function dataAlreadyInDB($injectionClass, $itemtype)
$destination_itemtype = $item::$itemtype_2;
}
$where .= " AND `$source_id`='" .
$this->getValueByItemtypeAndName($itemtype, $source_id) . "'";
$DB->escape($this->getValueByItemtypeAndName($itemtype, $source_id)) . "'";
if ($item->isField('itemtype')) {
$where .= " AND `$source_itemtype`='" .
$this->getValueByItemtypeAndName($itemtype, $source_itemtype) . "'";
$DB->escape($this->getValueByItemtypeAndName($itemtype, $source_itemtype)) . "'";
}
$where .= " AND `" . $destination_id . "`='" .
$this->getValueByItemtypeAndName($itemtype, $destination_id) . "'";
$DB->escape($this->getValueByItemtypeAndName($itemtype, $destination_id)) . "'";
$sql .= " WHERE 1 " . $where;
} else {
//Type is not a relation
Expand Down Expand Up @@ -1958,7 +1958,7 @@ private function dataAlreadyInDB($injectionClass, $itemtype)
} else {
//Type cannot be recursive
$where_entity = " AND `entities_id` = '" .
$this->getValueByItemtypeAndName($itemtype, 'entities_id') . "'";
$DB->escape($this->getValueByItemtypeAndName($itemtype, 'entities_id')) . "'";
}
} else { //If no entity assignment for this itemtype
$where_entity = "";
Expand All @@ -1972,25 +1972,25 @@ private function dataAlreadyInDB($injectionClass, $itemtype)
$email = $DB->escape($this->getValueByItemtypeAndName($itemtype, $field));
$where .= " AND `id` IN (SELECT `users_id` FROM glpi_useremails WHERE `email` = '$email') ";
} else {
$where .= " AND `" . $field . "`='" . (string) $this->getValueByItemtypeAndName($itemtype, $field) . "'";
$where .= " AND `" . $field . "`='" . $DB->escape((string) $this->getValueByItemtypeAndName($itemtype, $field)) . "'";
}
}
}
} else {
//Table contains an itemtype field
if ($injectionClass->isField('itemtype')) {
$where .= " AND `itemtype` = '" . $this->getValueByItemtypeAndName(
$where .= " AND `itemtype` = '" . $DB->escape($this->getValueByItemtypeAndName(
$itemtype,
'itemtype',
) . "'";
)) . "'";
}

//Table contains an items_id field
if ($injectionClass->isField('items_id')) {
$where .= " AND `items_id` = '" . $this->getValueByItemtypeAndName(
$where .= " AND `items_id` = '" . $DB->escape($this->getValueByItemtypeAndName(
$itemtype,
'items_id',
) . "'";
)) . "'";
}
}

Expand Down