A free, self-hostable news aggregator…
Fix log CRLF injection (#7883)
Inverlec44bb029c015
diff --git a/app/Models/Log.php b/app/Models/Log.phpindex 7760e76ca..5d3ddbe16 100644--- a/app/Models/Log.php+++ b/app/Models/Log.php@@ -4,6 +4,7 @@ declare(strict_types=1);class FreshRSS_Log extends Minz_Model {private string $date;+ /** @property 'error'|'warning'|'notice'|'debug'|'info' $level */private string $level;private string $information;@@ -20,6 +21,10 @@ class FreshRSS_Log extends Minz_Model {$this->date = $date;}public function _level(string $level): void {+ if (!in_array($level, ['error', 'warning', 'notice', 'debug', 'info'], true)) {+ $this->level = 'info';+ return;+ }$this->level = $level;}public function _info(string $information): void {diff --git a/lib/Minz/Log.php b/lib/Minz/Log.phpindex 8bf193ffe..df3c97904 100644--- a/lib/Minz/Log.php+++ b/lib/Minz/Log.php@@ -56,7 +56,7 @@ class Minz_Log {$level_label = 'info';}- $log = '[' . date('r') . '] [' . $level_label . '] --- ' . $information . "\n";+ $log = '[' . date('r') . '] [' . $level_label . '] --- ' . str_replace(["\r", "\n"], ' ', $information) . "\n";if (defined('COPY_LOG_TO_SYSLOG') && COPY_LOG_TO_SYSLOG) {syslog($level, '[' . $username . '] ' . trim($log));