Skip to content

Commit 0b88ad1

Browse files
committed
fix: HTML Injection in modules/utenti/edit.php
1 parent 57a2734 commit 0b88ad1

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

modules/utenti/ajax/select.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@
5151
$rs = $dbo->fetchArray($query);
5252
foreach ($rs as $r) {
5353
if ($prev != $r['optgroup']) {
54-
$results[] = ['text' => $r['optgroup'], 'children' => []];
54+
$results[] = ['text' => htmlspecialchars($r['optgroup'], ENT_QUOTES, 'UTF-8'), 'children' => []];
5555
$prev = $r['optgroup'];
5656
}
5757

5858
$results[count($results) - 1]['children'][] = [
5959
'id' => $r['id'],
60-
'text' => $r['descrizione'],
61-
'descrizione' => $r['descrizione'],
60+
'text' => htmlspecialchars($r['descrizione'], ENT_QUOTES, 'UTF-8'),
61+
'descrizione' => htmlspecialchars($r['descrizione'], ENT_QUOTES, 'UTF-8'),
6262
];
6363
}
6464

@@ -106,14 +106,14 @@
106106
$rs = $dbo->fetchArray($query);
107107
foreach ($rs as $r) {
108108
if ($prev != $r['optgroup']) {
109-
$results[] = ['text' => $r['optgroup'], 'children' => []];
109+
$results[] = ['text' => htmlspecialchars($r['optgroup'], ENT_QUOTES, 'UTF-8'), 'children' => []];
110110
$prev = $r['optgroup'];
111111
}
112112

113113
$results[count($results) - 1]['children'][] = [
114114
'id' => $r['id'],
115-
'text' => $r['descrizione'],
116-
'descrizione' => $r['descrizione'],
115+
'text' => htmlspecialchars($r['descrizione'], ENT_QUOTES, 'UTF-8'),
116+
'descrizione' => htmlspecialchars($r['descrizione'], ENT_QUOTES, 'UTF-8'),
117117
];
118118
}
119119

modules/utenti/edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<div class="card-header">
6262
<h3 class="card-title">
6363
<i class="fa fa-users mr-2"></i>'.tr('Utenti del gruppo: _GROUP_', [
64-
'_GROUP_' => '<span class="text-primary">'.$group->getTranslation('title').'</span>',
64+
'_GROUP_' => '<span class="text-primary">'.htmlspecialchars($group->getTranslation('title')).'</span>',
6565
]).'</h3>
6666
<div class="card-tools">
6767
<a data-card-widget="modal" data-href="'.$structure->fileurl('user.php').'?id_module='.$id_module.'&id_record='.$id_record.'" data-msg="" data-backto="record-edit" data-title="'.tr('Aggiungi utente').'" class="btn btn-sm btn-primary">
@@ -249,7 +249,7 @@
249249
<div class="card-header">
250250
<h3 class="card-title">
251251
<i class="fa fa-lock mr-2"></i>'.tr('Permessi del gruppo: _GROUP_', [
252-
'_GROUP_' => '<span class="text-primary">'.$record['nome'].'</span>',
252+
'_GROUP_' => '<span class="text-primary">'.htmlspecialchars($record['nome']).'</span>',
253253
]).'</h3>'.((empty($record['editable']) && ($record['nome'] != 'Amministratori')) ? '
254254
<div class="card-tools">
255255
<btn type="button" class="btn clickable btn-sm btn-warning float-right ask" data-msg="<small>'.tr('Verranno reimpostati i permessi di default per il gruppo '.$record['nome']).'.</small>" data-class="btn btn-warning" data-button="'.tr('Reimposta permessi').'" data-op="restore_permission">'.tr('Reimposta permessi').'</btn>

src/AJAX.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static function selectResults($query, $where, $filter = [], $search = [],
124124
foreach ($rows as $row) {
125125
$result = $row;
126126
foreach ($custom as $key => $value) {
127-
$result[$key] = $row[$value];
127+
$result[$key] = htmlspecialchars($row[$value] ?? '', ENT_QUOTES, 'UTF-8');
128128
}
129129

130130
$results[] = $result;

src/Modules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public static function getMainMenu($depth = 3)
312312
*/
313313
public static function link($modulo, $id_record = null, $testo = null, $alternativo = true, $extra = null, $blank = true, $anchor = null, $params = null)
314314
{
315-
$testo = isset($testo) ? nl2br($testo) : '';
315+
$testo = isset($testo) ? nl2br(htmlspecialchars($testo, ENT_QUOTES, 'UTF-8')) : '';
316316
$alternativo = is_bool($alternativo) && $alternativo ? $testo : $alternativo;
317317

318318
// Verifica se il testo contiene un'icona

0 commit comments

Comments
 (0)