mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 18:50:47 -04:00
Merge pull request #55989 from nextcloud/bugfix/noid/harden-profiler-write
fix(profiler): Harden profiler writes
This commit is contained in:
commit
bc1b17faa2
1 changed files with 14 additions and 5 deletions
|
|
@ -48,15 +48,17 @@ class FileProfilerStorage {
|
|||
[$csvToken, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode] = $values;
|
||||
$csvTime = (int)$csvTime;
|
||||
|
||||
if ($url && !str_contains($csvUrl, $url) || $method && !str_contains($csvMethod, $method) || $statusCode && !str_contains($csvStatusCode, $statusCode)) {
|
||||
if (($url && !str_contains($csvUrl, $url))
|
||||
|| ($method && !str_contains($csvMethod, $method))
|
||||
|| ($statusCode && !str_contains($csvStatusCode, $statusCode))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($start) && $csvTime < $start) {
|
||||
if ($start !== null && $csvTime < $start) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($end) && $csvTime > $end) {
|
||||
if ($end !== null && $csvTime > $end) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -154,20 +156,27 @@ class FileProfilerStorage {
|
|||
return false;
|
||||
}
|
||||
|
||||
fputcsv($file, [
|
||||
fputcsv($file, array_map([$this, 'escapeFormulae'], [
|
||||
$profile->getToken(),
|
||||
$profile->getMethod(),
|
||||
$profile->getUrl(),
|
||||
$profile->getTime(),
|
||||
$profile->getParentToken(),
|
||||
$profile->getStatusCode(),
|
||||
], escape: '');
|
||||
]), escape: '');
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function escapeFormulae(?string $value): ?string {
|
||||
if ($value !== null && preg_match('/^[=+\-@\t\r]/', $value)) {
|
||||
return "'" . $value;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets filename to store data, associated to the token.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue