Skip to content

Commit

Permalink
fix(targetticket,targetchange): escape text fields of targets
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Feb 6, 2020
1 parent 7d8934a commit 6c0d775
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions inc/targetchange.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
);
}

// Escape text fields
foreach (['target_name'] as $key) {
$input[$key] = $DB->escape($input[$key]);
}

// Assume that all questions are already imported
// convert question uuid into id
Expand Down
4 changes: 4 additions & 0 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
);
}

// Escape text fields
foreach (['target_name'] as $key) {
$input[$key] = $DB->escape($input[$key]);
}

// Assume that all questions are already imported
// convert question uuid into id
Expand Down
5 changes: 3 additions & 2 deletions tests/suite-unit/PluginFormcreatorTargetChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function testGetTargetItemtypeName() {
*/
public function testSetTargetEntity() {
global $CFG_GLPI;

// Disable notification to avoid output to console
$CFG_GLPI['use_notifications'] = '0';

Expand Down Expand Up @@ -339,7 +339,7 @@ public function testSetTargetEntity() {
'destination_entity_value' => '0',
]);
$instance->getFromDB($targetChange->getID());

// Disable notification to avoid output to console
$CFG_GLPI['use_notifications'] = '0';

Expand Down Expand Up @@ -465,6 +465,7 @@ public function testImport() {
$uuid = plugin_formcreator_getUuid();
$input = [
'name' => $this->getUniqueString(),
'target_name' => $this->getUniqueString(),
'content' => $this->getUniqueString(),
'impactcontent' => $this->getUniqueString(),
'controlistcontent' => $this->getUniqueString(),
Expand Down
1 change: 1 addition & 0 deletions tests/suite-unit/PluginFormcreatorTargetTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ public function testImport() {
$uuid = plugin_formcreator_getUuid();
$input = [
'name' => $this->getUniqueString(),
'target_name' => $this->getUniqueString(),
'content' => $this->getUniqueString(),
'due_date_rule' => \PluginFormcreatorTargetTicket::DUE_DATE_RULE_NONE,
'due_date_question' => '0',
Expand Down

0 comments on commit 6c0d775

Please sign in to comment.