Skip to content

Commit 56ddff2

Browse files
committed
fix(issue): SQL scaping problem when updating a ticket
1 parent 66bea30 commit 56ddff2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

hook.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,9 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
453453

454454
$validationStatus = PluginFormcreatorCommon::getTicketStatusForIssue($item);
455455

456-
$issueName = $item->fields['name'] != '' ? addslashes($item->fields['name']) : '(' . $item->getID() . ')';
456+
$issueName = $item->fields['name'] != ''
457+
? $item->fields['name']
458+
: '(' . $item->getID() . ')';
457459
$issue = new PluginFormcreatorIssue();
458460
$issue->getFromDBByCrit([
459461
'AND' => [
@@ -480,14 +482,14 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
480482
'items_id' => $id,
481483
'display_id' => "t_$id",
482484
'itemtype' => Ticket::class,
483-
'name' => $issueName,
485+
'name' => $DB->escape($issueName),
484486
'status' => $validationStatus,
485487
'date_creation' => $item->fields['date'],
486488
'date_mod' => $item->fields['date_mod'],
487489
'entities_id' => $item->fields['entities_id'],
488490
'is_recursive' => '0',
489491
'requester_id' => $requester,
490-
'comment' => addslashes($item->fields['content']),
492+
'comment' => $DB->escape($item->fields['content']),
491493
]);
492494
}
493495

@@ -611,7 +613,10 @@ function plugin_formcreator_hook_update_ticketvalidation(CommonDBTM $item) {
611613
if ($issue->isNewItem()) {
612614
return;
613615
}
614-
$issue->update(['status' => $status] + $issue->fields);
616+
$issue->update([
617+
'id' => $issue->getID(),
618+
'status' => $status
619+
]);
615620
}
616621

617622
function plugin_formcreator_hook_update_itilFollowup($followup) {

0 commit comments

Comments
 (0)