Skip to content

Commit f183091

Browse files
committed
fix(question): remove abusive encoding
1 parent d723a47 commit f183091

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

inc/question.class.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ private function checkBeforeSave($input) {
238238
Session::addMessageAfterRedirect(__('The title is required', 'formcreator'), false, ERROR);
239239
return [];
240240
}
241-
$input['name'] = addslashes($input['name']);
242241
}
243242

244243
// - field type is required
@@ -313,7 +312,7 @@ public function prepareInputForAdd($input) {
313312
foreach ($input as $key => $value) {
314313
if ($input['fieldtype'] != 'dropdown'
315314
|| $input['fieldtype'] != 'dropdown' && $key != 'values') {
316-
if ($key != 'regex') {
315+
if ($key != 'regex' && $key != 'name') {
317316
$input[$key] = plugin_formcreator_encode($value);
318317
}
319318
}
@@ -378,7 +377,7 @@ public function prepareInputForUpdate($input) {
378377
&& !($input['fieldtype'] == 'checkboxes' && ($key == 'values' || $key == 'default_values'))
379378
&& !($input['fieldtype'] == 'radios' && ($key == 'values' || $key == 'default_values'))
380379
&& !($input['fieldtype'] == 'multiselect' && ($key == 'values' || $key == 'default_values'))) {
381-
if ($key != 'regex') {
380+
if ($key != 'regex' && $key != 'name') {
382381
$input[$key] = plugin_formcreator_encode($value);
383382
}
384383
} else {

install/update_dev.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@ function plugin_formcreator_update_dev() {
1616
'WHERE' => ['fieldtype' => 'textarea']
1717
];
1818
foreach ($DB->request($request) as $row) {
19-
$answer = Toolbox::addslashes_deep(html_entity_decode($row['answer']));
19+
$answer = Toolbox::addslashes_deep(html_entity_decode($row['answer'], ENT_QUOTES|ENT_HTML5));
2020
$id = $row['id'];
2121
$DB->query("UPDATE `glpi_plugin_formcreator_answers` SET `answer`='$answer' WHERE `id` = '$id'");
2222
}
23+
24+
$request = [
25+
'FROM' => 'glpi_plugin_formcreator_questions',
26+
];
27+
foreach ($DB->request($request) as $row) {
28+
$id = $row['id'];
29+
$name = Toolbox::addslashes_deep(html_entity_decode($row['name'], ENT_QUOTES|ENT_HTML5));
30+
$id = $row['id'];
31+
$DB->query("UPDATE `glpi_plugin_formcreator_questions` SET `name`='$name' WHERE `id` = '$id'");
32+
}
2333
}

0 commit comments

Comments
 (0)