diff --git a/inc/command/cleanticketscommand.class.php b/inc/command/cleanticketscommand.class.php
new file mode 100644
index 000000000..65080a896
--- /dev/null
+++ b/inc/command/cleanticketscommand.class.php
@@ -0,0 +1,196 @@
+.
+ * ---------------------------------------------------------------------
+ * @copyright Copyright © 2011 - 2021 Teclib'
+ * @license http://www.gnu.org/licenses/gpl.txt GPLv3+
+ * @link https://github.com/pluginsGLPI/formcreator/
+ * @link https://pluginsglpi.github.io/formcreator/
+ * @link http://plugins.glpi-project.org/#/plugin/formcreator
+ * ---------------------------------------------------------------------
+ */
+
+namespace GlpiPlugin\Formcreator\Command;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Ticket;
+use Item_Ticket;
+use PluginFormcreatorFormAnswer;
+use Glpi\Toolbox\Sanitizer;
+
+class CleanTicketsCommand extends Command
+{
+ protected function configure() {
+ $this
+ ->setName('glpi:plugins:formcreator:clean_tickets')
+ ->setDescription("Clean Tickets having visible HTML tags in their content");
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $output->write("
=> <p> => <p> + * + * @param InputInterface $input + * @param OutputInterface $output + * @return void + */ + protected function fixBadForm_1(InputInterface $input, OutputInterface $output) { + global $DB; + + // Search tickets having HTML tags in content in the following form + // <p>Hello world</p> + // Hello world is between
and
, but with wrong escaping + $itemTicketTable = Item_Ticket::getTable(); + $ticketTable = Ticket::getTable(); + $pattern = '<'; + // $pattern = str_replace(';', '\\;', $pattern); + $tickets = $DB->request([ + 'SELECT' => [$ticketTable => [Ticket::getIndexName(), 'content']], + 'FROM' => $ticketTable, + 'INNER JOIN' => [ + $itemTicketTable => [ + 'FKEY' => [ + $ticketTable => Ticket::getIndexName(), + $itemTicketTable => Ticket::getForeignKeyField(), + ], + 'AND' => [ + "$itemTicketTable.itemtype" => PluginFormcreatorFormAnswer::getType(), + ] + ], + ], + 'WHERE' => [ + "$ticketTable.content" => ['LIKE', '%' . $pattern . '%'], // Matches bad encoding for '<' + ], + ]); + + $count = $tickets->count(); + if ($count < 1) { + $output->writeln('