Skip to content

Commit

Permalink
fix(condition): conditions don't work when not sanitized
Browse files Browse the repository at this point in the history
may occur whern a condition contains characters like &, > and created in Formcreator < 2.13.0
  • Loading branch information
btry committed May 5, 2023
1 parent e518b7d commit f2b0fad
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions install/upgrade_to_2.13.6.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function isResyncIssuesRequired() {
public function upgrade(Migration $migration) {
$this->migration = $migration;
$this->migrateToRichText();
$this->sanitizeConditions();
}

public function migrateToRichText() {
Expand Down Expand Up @@ -82,4 +83,24 @@ public function migrateToRichText() {
}
}
}

/**
* Conditions written in Formcreator < 2.13.0 are not sanitized.
* With versions >= 2.13.0, comparisons require sanitization
*
* @return void
*/
protected function sanitizeConditions() {
global $DB;

$table = 'glpi_plugin_formcreator_conditions';
$request = $DB->request([
'SELECT' => ['id', 'show_value'],
'FROM' => $table,
]);
foreach ($request as $row) {
$row['show_value'] = Sanitizer::sanitize($row['show_value'], true);
$DB->update($table, $row, ['id' => $row['id']]);
}
}
}

0 comments on commit f2b0fad

Please sign in to comment.