Skip to content

Commit 909da61

Browse files
authored
Merge pull request #13 from aryehraber/fix/log-output-sanitization-issue
Log output sanitization issue
2 parents e1d3778 + 1d4ae3f commit 909da61

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

resources/views/show.blade.php

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,32 @@
6363
</div>
6464

6565
<div class="card p-0">
66-
<table class="data-table">
67-
<thead class="pb-1">
68-
<th>{{ __('Level') }}</th>
69-
<th>{{ __('Context') }}</th>
70-
<th>{{ __('Date') }}</th>
71-
<th>{{ __('Content') }}</th>
72-
</thead>
73-
<tbody>
74-
@foreach ($logs as $key => $log)
75-
<tr @if($log['stack']) style="cursor: zoom-in;" data-expandable @endif>
76-
<td style="min-width: 120px; vertical-align: top;">{{ $log['level'] }}</td>
77-
<td style="min-width: 120px; vertical-align: top;">{{ $log['context'] }}</td>
78-
<td style="min-width: 200px; vertical-align: top;">{{ $log['date'] }}</td>
79-
<td class="w-full font-mono text-xs">
80-
{{ $log['text'] }}
66+
<div class="w-full overflow-auto">
67+
<table class="data-table">
68+
<thead class="pb-1">
69+
<th>{{ __('Level') }}</th>
70+
<th>{{ __('Context') }}</th>
71+
<th>{{ __('Date') }}</th>
72+
<th>{{ __('Content') }}</th>
73+
</thead>
74+
<tbody>
75+
@foreach ($logs as $key => $log)
76+
<tr @if($log['stack']) style="cursor: zoom-in;" data-expandable @endif>
77+
<td style="min-width: 120px; vertical-align: top;">{{ $log['level'] }}</td>
78+
<td style="min-width: 120px; vertical-align: top;">{{ $log['context'] }}</td>
79+
<td style="min-width: 200px; vertical-align: top;">{{ $log['date'] }}</td>
80+
<td class="w-full font-mono text-xs">
81+
{{ $log['text'] }}
8182

82-
@if($log['in_file'])) <br>{{ $log['in_file'] }} @endif
83+
@if($log['in_file'])) <br>{{ $log['in_file'] }} @endif
8384

84-
@if($log['stack']) <div class="hidden whitespace-pre-wrap" data-stack>{{ trim($log['stack']) }}</div> @endif
85-
</td>
86-
</tr>
87-
@endforeach
88-
</tbody>
89-
</table>
85+
@if($log['stack']) <div class="hidden whitespace-pre-wrap" data-stack>{{ trim($log['stack']) }}</div> @endif
86+
</td>
87+
</tr>
88+
@endforeach
89+
</tbody>
90+
</table>
91+
</div>
9092
</div>
9193
@else
9294
<p>No log files found.</p>

src/LogbookController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function show(Request $request, LaravelLogViewer $logviewer)
1919
}
2020

2121
return view('logbook::show', [
22-
'logs' => $logviewer->all(),
22+
'logs' => $this->sanitize($logviewer->all()),
2323
'files' => $logviewer->getFiles(true),
2424
'currentFile' => $logviewer->getFileName(),
2525
]);
@@ -43,4 +43,11 @@ public function destroy(Request $request, LaravelLogViewer $logviewer)
4343

4444
return redirect(cp_route('utilities.logbook.show'))->with('success', 'Log file deleted.');
4545
}
46+
47+
protected function sanitize(array $log)
48+
{
49+
return array_map(function ($val) {
50+
return str_replace(['{{', '}}'], ['&#123;&#123;', '&#125;&#125;'], $val);
51+
}, $log);
52+
}
4653
}

0 commit comments

Comments
 (0)