Skip to content

Commit 2b524cb

Browse files
committed
Merge remote-tracking branch 'origin/support/2.13.0' into support/2.14.0
2 parents 522b9b8 + 83ea716 commit 2b524cb

4 files changed

Lines changed: 27 additions & 16 deletions

File tree

inc/formanswer.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ public function prepareInputForAdd($input) {
890890
}
891891

892892
try {
893-
$input['name'] = $DB->escape($this->parseTags($form->fields['formanswer_name']));
893+
$input['name'] = $this->parseTags($form->fields['formanswer_name']);
894894
} catch (Exception $e) {
895895
// A fatal error caught during parsing of tags
896896
$GLPI->getErrorHandler()->handleException($e, false);

inc/targetchange.class.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -621,20 +621,15 @@ protected function getTargetTemplate(array $data): int {
621621
'FROM' => ITILCategory::getTable(),
622622
'WHERE' => ['id' => $data['itilcategories_id']]
623623
]);
624-
if ($row = $rows->current()) { // assign change template according to resulting change category
624+
if ($row = $rows->current()) {
625+
// assign change template according to resulting change category
625626
return $row[$targetTemplateFk];
626627
}
627628
}
628629

629630
return $this->fields[$targetTemplateFk] ?? 0;
630631
}
631632

632-
public function getDefaultData(PluginFormcreatorFormAnswer $formanswer): array {
633-
$data = parent::getDefaultData($formanswer);
634-
635-
return $data;
636-
}
637-
638633
/**
639634
* Save form data to the target
640635
*

inc/targetticket.class.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -803,20 +803,15 @@ protected function getTargetTemplate(array $data): int {
803803
'FROM' => ITILCategory::getTable(),
804804
'WHERE' => ['id' => $data['itilcategories_id']]
805805
]);
806-
if ($row = $rows->current()) { // assign ticket template according to resulting ticket category and ticket type
806+
if ($row = $rows->current()) {
807+
// assign ticket template according to resulting ticket category and ticket type
807808
return ($data['type'] == Ticket::INCIDENT_TYPE
808809
? $row["{$targetTemplateFk}_incident"]
809810
: $row["{$targetTemplateFk}_demand"]);
810811
}
811812
}
812813

813-
return $this->fields['tickettemplates_id'] ?? 0;
814-
}
815-
816-
public function getDefaultData(PluginFormcreatorFormAnswer $formanswer): array {
817-
$data = parent::getDefaultData($formanswer);
818-
819-
return $data;
814+
return $this->fields[$targetTemplateFk] ?? 0;
820815
}
821816

822817
/**

install/upgrade_to_2.13.6.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function isResyncIssuesRequired() {
4646
public function upgrade(Migration $migration) {
4747
$this->migration = $migration;
4848
$this->migrateToRichText();
49+
$this->sanitizeConditions();
4950
}
5051

5152
public function migrateToRichText() {
@@ -82,4 +83,24 @@ public function migrateToRichText() {
8283
}
8384
}
8485
}
86+
87+
/**
88+
* Conditions written in Formcreator < 2.13.0 are not sanitized.
89+
* With versions >= 2.13.0, comparisons require sanitization
90+
*
91+
* @return void
92+
*/
93+
protected function sanitizeConditions() {
94+
global $DB;
95+
96+
$table = 'glpi_plugin_formcreator_conditions';
97+
$request = $DB->request([
98+
'SELECT' => ['id', 'show_value'],
99+
'FROM' => $table,
100+
]);
101+
foreach ($request as $row) {
102+
$row['show_value'] = Sanitizer::sanitize($row['show_value'], true);
103+
$DB->update($table, $row, ['id' => $row['id']]);
104+
}
105+
}
85106
}

0 commit comments

Comments
 (0)