Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,22 @@ public function respond()
if ($request->getGet('debugbar_time')) {
helper('security');

// Validate and sanitize the debugbar_time parameter -- ss
$debugbarTime = $request->getGet('debugbar_time');
if (! preg_match('/^\d+(\.\d+)?$/', $debugbarTime)) {
throw new InvalidArgumentException('Invalid debugbar_time parameter.');
}

// Negotiate the content-type to format the output
$format = $request->negotiate('media', ['text/html', 'application/json', 'application/xml']);
$format = explode('/', $format)[1];

$filename = sanitize_filename('debugbar_' . $request->getGet('debugbar_time'));
$filename = WRITEPATH . 'debugbar/' . $filename . '.json';

if (is_file($filename)) {
if (is_file($filename) && is_readable($filename)) {
// Show the toolbar if it exists
echo $this->format(file_get_contents($filename), $format);
echo htmlspecialchars($this->format(file_get_contents($filename), $format), ENT_QUOTES, 'UTF-8');

exit;
}
Expand Down