Skip to content

Commit

Permalink
fix(csv): fix #5279 always force subject to be a string
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Yoda-BZH authored and nilmerg committed Nov 4, 2024
1 parent 9f14c32 commit 41a2aed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/Icinga/File/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down

0 comments on commit 41a2aed

Please sign in to comment.