Merge pull request #10315 from snipe/fixes/escape_custom_fields_in_api_response

Escape custom field values in API response
This commit is contained in:
snipe 2021-11-15 20:33:51 -08:00 committed by GitHub
commit 7ce5993f5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -93,15 +93,15 @@ class AssetsTransformer
$value = (Gate::allows('superadmin')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted')); $value = (Gate::allows('superadmin')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted'));
$fields_array[$field->name] = [ $fields_array[$field->name] = [
'field' => $field->convertUnicodeDbSlug(), 'field' => e($field->convertUnicodeDbSlug()),
'value' => $value, 'value' => e($value),
'field_format' => $field->format, 'field_format' => $field->format,
]; ];
} else { } else {
$fields_array[$field->name] = [ $fields_array[$field->name] = [
'field' => $field->convertUnicodeDbSlug(), 'field' => e($field->convertUnicodeDbSlug()),
'value' => $asset->{$field->convertUnicodeDbSlug()}, 'value' => e($asset->{$field->convertUnicodeDbSlug()}),
'field_format' => $field->format, 'field_format' => $field->format,
]; ];
@ -134,7 +134,7 @@ class AssetsTransformer
'id' => $component->id, 'id' => $component->id,
'pivot_id' => $component->pivot->id, 'pivot_id' => $component->pivot->id,
'name' => $component->name, 'name' => e($component->name),
'qty' => $component->pivot->assigned_qty, 'qty' => $component->pivot->assigned_qty,
'price_cost' => $component->purchase_cost, 'price_cost' => $component->purchase_cost,
'purchase_total' => $component->purchase_cost * $component->pivot->assigned_qty, 'purchase_total' => $component->purchase_cost * $component->pivot->assigned_qty,