Fix CSV export formatting and ensure cached states are initialized properly

This commit is contained in:
2025-12-10 12:07:02 -05:00
parent 00d4a50e9d
commit 5c76a381d0
2 changed files with 6 additions and 5 deletions

View File

@@ -1653,11 +1653,11 @@ class Firewall extends Component
if ($this->cachedStates === null ||
$this->cacheTimestamp === null ||
($now - $this->cacheTimestamp) > self::STATE_CACHE_TTL) {
$this->cachedStates = $client->listStates();
$this->cachedStates = $client->listStates() ?? [];
$this->cacheTimestamp = $now;
}
$allStates = $this->cachedStates;
$allStates = $this->cachedStates ?? [];
// Normalize search parameters once
$normalizedSourceIP = strtolower(trim($sourceIP));

View File

@@ -1131,8 +1131,9 @@
rows.forEach(row => {
csvContent += row.map(cell => {
const str = String(cell);
if (str.includes(',') || str.includes('"') || str.includes('\n')) {
return '"' + str.replace(/"/g, '""') + '"';
const dq = String.fromCharCode(34);
if (str.indexOf(',') !== -1 || str.indexOf(dq) !== -1 || str.indexOf('\n') !== -1) {
return dq + str.replace(new RegExp(dq, 'g'), dq + dq) + dq;
}
return str;
}).join(',') + '\n';
@@ -1142,7 +1143,7 @@
const link = document.createElement('a');
const timestamp = new Date().toISOString().slice(0, 19).replace(/[T:]/g, '-');
link.href = URL.createObjectURL(blob);
link.download = `network-analysis-${this.sourceIP}-${timestamp}.csv`;
link.download = 'network-analysis-' + this.sourceIP + '-' + timestamp + '.csv';
link.click();
URL.revokeObjectURL(link.href);
}