Fix CSV export formatting and ensure cached states are initialized properly
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user