From 41a2aed0b519da37c03a1cf3546ae3ece95aaae5 Mon Sep 17 00:00:00 2001 From: Yoda-BZH Date: Thu, 31 Oct 2024 11:38:19 +0100 Subject: [PATCH] fix(csv): fix #5279 always force subject to be a string When performing a str_replace, subject should always be a string. If passing a non-existent column or empty column, subject may be null This ensure str_replace is called when subject is actually a string (not NULL) --- library/Icinga/File/Csv.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/File/Csv.php b/library/Icinga/File/Csv.php index 56ee233eeb..d189780403 100644 --- a/library/Icinga/File/Csv.php +++ b/library/Icinga/File/Csv.php @@ -37,7 +37,7 @@ public function __toString() } $out = array(); foreach ($row as & $val) { - $out[] = '"' . str_replace('"', '""', $val) . '"'; + $out[] = '"' . ($val ? str_replace('"', '""', $val) : '') . '"'; } $csv .= implode(',', $out) . "\r\n"; }