MDL-66762 tool_dataprivacy: Sanitize the extra fields in the webservice
This commit is contained in:
committed by
Adrian Greeve
parent
7455b741c9
commit
6ac0f57073
@@ -713,7 +713,6 @@ class external extends external_api {
|
||||
|
||||
list($sql, $params) = users_search_sql($query, '', false, $extrafields, $excludedusers);
|
||||
$users = $DB->get_records_select('user', $sql, $params, $sort, $fields, 0, 30);
|
||||
|
||||
$useroptions = [];
|
||||
foreach ($users as $user) {
|
||||
$useroption = (object)[
|
||||
@@ -722,9 +721,10 @@ class external extends external_api {
|
||||
];
|
||||
$useroption->extrafields = [];
|
||||
foreach ($extrafields as $extrafield) {
|
||||
// Sanitize the extra fields to prevent potential XSS exploit.
|
||||
$useroption->extrafields[] = (object)[
|
||||
'name' => $extrafield,
|
||||
'value' => $user->{$extrafield}
|
||||
'value' => s($user->$extrafield)
|
||||
];
|
||||
}
|
||||
$useroptions[$user->id] = $useroption;
|
||||
@@ -748,7 +748,7 @@ class external extends external_api {
|
||||
'extrafields' => new external_multiple_structure(
|
||||
new external_single_structure([
|
||||
'name' => new external_value(PARAM_TEXT, 'Name of the extrafield.'),
|
||||
'value' => new external_value(PARAM_RAW_TRIMMED, 'Value of the extrafield.')
|
||||
'value' => new external_value(PARAM_TEXT, 'Value of the extrafield.')
|
||||
]
|
||||
), 'List of extra fields', VALUE_OPTIONAL
|
||||
)
|
||||
|
||||
@@ -47,6 +47,6 @@
|
||||
<span>
|
||||
<span>{{fullname}}</span>
|
||||
{{#extrafields}}
|
||||
<span><small>{{value}}</small></span>
|
||||
<span><small>{{{value}}}</small></span>
|
||||
{{/extrafields}}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user