Skip to content

Commit f2b0fad

Browse files
committed
fix(condition): conditions don't work when not sanitized
may occur whern a condition contains characters like &, > and created in Formcreator < 2.13.0
1 parent e518b7d commit f2b0fad

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

install/upgrade_to_2.13.6.php

+21
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)