Skip to content
Closed
Changes from 1 commit
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
16 changes: 8 additions & 8 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,25 +484,25 @@ 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('/^[a-zA-Z0-9_]+$/', $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;
}

// Filename not found
http_response_code(404);

exit; // Exit here is needed to avoid loading the index page
}
}

/**
Expand Down