Skip to content

Commit

Permalink
Properly escape log_meta values
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Mar 19, 2019
1 parent dec7789 commit c7c2b86
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/Http/Transformers/ActionlogsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ public function transformActionlog (Actionlog $actionlog, $settings = null)
if ($actionlog->filename!='') {
$icon = e(\App\Helpers\Helper::filetype_icon($actionlog->filename));
}

// This is necessary since we can't escape special characters within a JSON object
if (($actionlog->log_meta) && ($actionlog->log_meta!='')) {
$meta_array = json_decode($actionlog->log_meta);
foreach ($meta_array as $key => $value) {
foreach ($value as $meta_key => $meta_value) {
$clean_meta[$key][$meta_key] = e($meta_value);
}
}
}


$array = [
'id' => (int) $actionlog->id,
'icon' => $icon,
Expand Down Expand Up @@ -64,7 +76,7 @@ public function transformActionlog (Actionlog $actionlog, $settings = null)

'note' => ($actionlog->note) ? e($actionlog->note): null,
'signature_file' => ($actionlog->accept_signature) ? route('log.signature.view', ['filename' => $actionlog->accept_signature ]) : null,
'log_meta' => ($actionlog->log_meta) ? json_decode($actionlog->log_meta): null,
'log_meta' => ((isset($clean_meta)) && (is_array($clean_meta))) ? $clean_meta: null,


];
Expand Down

0 comments on commit c7c2b86

Please sign in to comment.